Commit 9550c031 authored by 乾坤平台's avatar 乾坤平台 Committed by 季圣华
Browse files

!16 修复一系列问题

Merge pull request !16 from 乾坤平台/master
parents fc03d050 c4623555
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -2,7 +2,29 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<profiles>
<profile>
<id>dev</id>
<properties>
<activatedProperties>dev</activatedProperties>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>test</id>
<properties>
<activatedProperties>test</activatedProperties>
</properties>
</profile>
<profile>
<id>prod</id>
<properties>
<activatedProperties>prod</activatedProperties>
</properties>
</profile>
</profiles>
<groupId>com.jsh</groupId>
<artifactId>jshERP</artifactId>
<version>2.0.2-SNAPSHOT</version>
......@@ -14,7 +36,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.1.RELEASE</version>
<version>2.0.0.RELEASE</version>
</parent>
<properties>
......
This diff is collapsed.
package com.jsh.erp;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
@MapperScan(basePackages = {"com.jsh.erp.datasource.mappers"})
@EnableScheduling
public class ErpApplication {
public static void main(String[] args) {
SpringApplication.run(ErpApplication.class, args);
}
}
package com.jsh.erp;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
@MapperScan(basePackages = {"com.jsh.erp.datasource.mappers"})
@EnableScheduling
public class ErpApplication{
public static void main(String[] args) {
SpringApplication.run(ErpApplication.class, args);
}
}
package com.jsh.erp.config;
import com.alibaba.druid.pool.DruidDataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.sql.DataSource;
@Configuration
@EnableTransactionManagement(proxyTargetClass = true)
public class DbConfig {
private static final Logger logger = LoggerFactory.getLogger(DbConfig.class);
@Bean(name = "erpDatasource")
@Primary
public DataSource erpDatasource(ErpDatasourceProperties properties){
try {
DruidDataSource datasource = new DruidDataSource();
datasource.setDriverClassName(properties.driverClassName);
datasource.setUrl(properties.url);
datasource.setUsername(properties.username);
datasource.setPassword(properties.password);
datasource.setInitialSize(1);
datasource.setMinIdle(1);
datasource.setMaxWait(60000);
datasource.setMaxActive(5);
datasource.setTimeBetweenEvictionRunsMillis(60000);
datasource.setValidationQuery("select '1'");
datasource.setTestOnBorrow(false);
datasource.setTestOnReturn(false);
datasource.setTestWhileIdle(true);
datasource.setPoolPreparedStatements(true);
datasource.setMaxOpenPreparedStatements(20);
datasource.setMinEvictableIdleTimeMillis(300000);
datasource.init();
return datasource;
}catch (Exception e){
logger.error("服务启动失败,jsh_erp数据库Datasource初始化失败:"+e.getMessage());
throw new IllegalArgumentException(e);
}
}
@Bean
@Primary
public JdbcTemplate jdbcTemplate(@Qualifier("erpDatasource") DataSource dataSource) {
return new JdbcTemplate(dataSource);
}
@Configuration
@ConfigurationProperties(prefix = "erpDatasource")
public static class ErpDatasourceProperties {
private String driverClassName;
private String url;
private String username;
private String password;
public String getDriverClassName() {
return driverClassName;
}
public void setDriverClassName(String driverClassName) {
this.driverClassName = driverClassName;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment