升级springboot版本依赖到2.0,修复部分文件内容乱码,加入配置文件为properties
This commit is contained in:
@@ -1,97 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,40 +1,33 @@
|
||||
package com.jsh.erp.config;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
|
||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import java.io.File;
|
||||
|
||||
@Configuration
|
||||
public class WebConfig {
|
||||
private static final Logger logger = LoggerFactory.getLogger(WebConfig.class);
|
||||
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "web.front")
|
||||
public static class FrontEnd implements EmbeddedServletContainerCustomizer {
|
||||
private File baseDir;
|
||||
|
||||
public File getBaseDir() {
|
||||
return baseDir;
|
||||
}
|
||||
|
||||
public void setBaseDir(File baseDir) {
|
||||
this.baseDir = baseDir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customize(ConfigurableEmbeddedServletContainer container) {
|
||||
if (!baseDir.exists()) {
|
||||
if (!baseDir.mkdir()) {
|
||||
logger.info("create web.front base path:" + baseDir + " failed!already exists!");
|
||||
} else {
|
||||
logger.info("create web.front base path:" + baseDir + " success!");
|
||||
}
|
||||
}
|
||||
container.setDocumentRoot(baseDir);
|
||||
}
|
||||
}
|
||||
package com.jsh.erp.config;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
|
||||
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
//@Configuration
|
||||
public class WebConfig {
|
||||
private static final Logger logger = LoggerFactory.getLogger(WebConfig.class);
|
||||
|
||||
@Configuration
|
||||
public static class FrontEnd implements WebServerFactoryCustomizer<ConfigurableServletWebServerFactory> {
|
||||
@Value("${web.front.baseDir}")
|
||||
private File baseDir;
|
||||
|
||||
@Override
|
||||
public void customize(ConfigurableServletWebServerFactory factory) {
|
||||
if (!baseDir.exists()) {
|
||||
if (!baseDir.mkdir()) {
|
||||
logger.info("create web.front base path:" + baseDir + " failed!already exists!");
|
||||
} else {
|
||||
logger.info("create web.front base path:" + baseDir + " success!");
|
||||
}
|
||||
}
|
||||
factory.setDocumentRoot(baseDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
4
src/main/resources/application-dev.properties
Normal file
4
src/main/resources/application-dev.properties
Normal file
@@ -0,0 +1,4 @@
|
||||
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/jsh_erp?useUnicode=true&characterEncoding=utf8&useCursorFetch=true&defaultFetchSize=500&allowMultiQueries=true&rewriteBatchedStatements=true&useSSL=false
|
||||
spring.datasource.driverClassName=com.mysql.jdbc.Driver
|
||||
spring.datasource.username=root
|
||||
spring.datasource.password=123456
|
||||
0
src/main/resources/application-prod.properties
Normal file
0
src/main/resources/application-prod.properties
Normal file
0
src/main/resources/application-test.properties
Normal file
0
src/main/resources/application-test.properties
Normal file
37
src/main/resources/application.properties
Normal file
37
src/main/resources/application.properties
Normal file
@@ -0,0 +1,37 @@
|
||||
server.port=9000
|
||||
#spring.application.name=erp
|
||||
#eureka.client.service-url.defaultZone=http://sinldo-eureka:8001/eureka/
|
||||
#eureka.client.service-url.defaultZone=http://localhost:8001/eureka/
|
||||
#eureka.instance.instance-id=${spring.application.name}-instance-${random.value}
|
||||
#eureka.instance.prefer-ip-address=true
|
||||
spring.profiles.active=@activatedProperties@
|
||||
#generatorConfigרÓÃÊôÐÔ
|
||||
project=src/main/java
|
||||
resource=src/main/resources
|
||||
web.front.baseDir=erp_web
|
||||
#web.front.baseDir=erp_web
|
||||
mybatis.type-aliases-package=com.chinamobile.model.*
|
||||
mybatis.mapper-locations=classpath:./mapper_xml/*.xml
|
||||
|
||||
|
||||
spring.cas.sign-out-filters=/logout
|
||||
spring.cas.auth-filters=/*
|
||||
spring.cas.validate-filters=/*
|
||||
spring.cas.request-wrapper-filters=/*
|
||||
spring.cas.assertion-filters=/*
|
||||
spring.cas.cas-server-login-url=http://localhost:8080/login
|
||||
spring.cas.cas-server-url-prefix=http://localhost:8080
|
||||
spring.cas.redirect-after-validation=true
|
||||
spring.cas.use-session=true
|
||||
spring.cas.server-name=http://localhost:9000
|
||||
|
||||
|
||||
##¾²Ì¬×ÊԴ·¾¶
|
||||
#spring.mvc.view.prefix=/templates/
|
||||
#spring.mvc.view.suffix=.html
|
||||
#spring.mvc.static-path-pattern=/**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
server:
|
||||
port: 80
|
||||
erpDatasource:
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
url: jdbc:mysql://127.0.0.1:3306/jsh_erp?useUnicode=true&characterEncoding=utf8&useCursorFetch=true&defaultFetchSize=500&allowMultiQueries=true&rewriteBatchedStatements=true&useSSL=false
|
||||
username: root
|
||||
password: 1234
|
||||
web:
|
||||
front:
|
||||
base-dir: erp_web
|
||||
mybatis:
|
||||
mapperLocations: classpath:mapper_xml/*.xml #一定要对应mapper映射xml文件的所在路径
|
||||
executorType: SIMPLE
|
||||
Reference in New Issue
Block a user