没完成整改

This commit is contained in:
黄晓 2020-12-04 17:53:04 +08:00
parent 830ea83dfa
commit d6139a1c6b
8 changed files with 32 additions and 85 deletions

17
pom.xml
View File

@ -5,22 +5,21 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.chinaweal.youfool</groupId> <groupId>com.chinaweal.youfool</groupId>
<artifactId>prj-springboot-template</artifactId> <artifactId>youfool-prj-springboot-template</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>1.0.0-SNAPSHOT</version>
<packaging>war</packaging> <packaging>war</packaging>
<name>${project.artifactId}</name>
<name>prj-springboot-template</name>
<url>https://www.chinaweal.com.cn</url> <url>https://www.chinaweal.com.cn</url>
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.6.RELEASE</version> <version>2.3.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository --> <relativePath/> <!-- lookup parent from repository -->
</parent> </parent>
<properties> <properties>
<java.version>1.8</java.version> <java.version>1.8</java.version>
<postgresql.version>42.2.8</postgresql.version> <postgresql.version>42.2.8</postgresql.version>
<easyexcel.version>2.2.2</easyexcel.version>
<skipTests>true</skipTests> <skipTests>true</skipTests>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.source>1.8</maven.compiler.source>
@ -32,7 +31,7 @@
<dependency> <dependency>
<groupId>com.chinaweal.youfool</groupId> <groupId>com.chinaweal.youfool</groupId>
<artifactId>youfool-framework-springboot</artifactId> <artifactId>youfool-framework-springboot</artifactId>
<version>1.1.0-SNAPSHOT</version> <version>2.0.0-SNAPSHOT</version>
</dependency> </dependency>
<!--postgresql--> <!--postgresql-->
<dependency> <dependency>
@ -40,12 +39,6 @@
<artifactId>postgresql</artifactId> <artifactId>postgresql</artifactId>
<version>${postgresql.version}</version> <version>${postgresql.version}</version>
</dependency> </dependency>
<!--druid-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.21</version>
</dependency>
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>

View File

@ -19,39 +19,38 @@ import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import javax.sql.DataSource; import javax.sql.DataSource;
/** /**
* youfool基础的数据源 * cms基础的数据源
*/ */
@Configuration @Configuration
@MapperScan(basePackages = "com.chinaweal.youfool.framework.springboot.**.mapper", sqlSessionTemplateRef = "youfoolSqlSessionTemplate") @MapperScan(basePackages = "com.chinaweal.youfool.framework.springboot.**.mapper", sqlSessionTemplateRef = "cmsSqlSessionTemplate")
public class YoufoolDataSource { public class CmsDataSource {
@Bean(name = "cmsDS", initMethod = "init", destroyMethod = "close")
@Bean(name = "youfoolDS", initMethod = "init", destroyMethod = "close") @ConfigurationProperties(prefix = "spring.datasource.cms")
@ConfigurationProperties(prefix = "spring.datasource.youfool")
public DruidDataSource dataSource() { public DruidDataSource dataSource() {
return DruidDataSourceBuilder.create().build(); return DruidDataSourceBuilder.create().build();
} }
@Bean(name = "youfoolSqlSessionFactory") @Bean(name = "cmsSqlSessionFactory")
public MybatisSqlSessionFactoryBean sqlSessionFactory(@Qualifier("youfoolDS") DataSource dataSource) throws Exception { public MybatisSqlSessionFactoryBean sqlSessionFactory(@Qualifier("cmsDS") DataSource dataSource) throws Exception {
MybatisSqlSessionFactoryBean bean = new MybatisSqlSessionFactoryBean(); MybatisSqlSessionFactoryBean bean = new MybatisSqlSessionFactoryBean();
bean.setDataSource(dataSource); bean.setDataSource(dataSource);
GlobalConfig globalConfig = new GlobalConfig(); GlobalConfig globalConfig = new GlobalConfig();
globalConfig.setMetaObjectHandler(new CommonMetaObjectHandler()); globalConfig.setMetaObjectHandler(new CommonMetaObjectHandler());
bean.setGlobalConfig(globalConfig); bean.setGlobalConfig(globalConfig);
bean.setConfigLocation(new ClassPathResource("youfool/mybatis/mybatis-config.xml")); bean.setConfigLocation(new ClassPathResource("cms/mybatis/mybatis-config.xml"));
bean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath*:youfool/mybatis/mapper/**/*.xml")); bean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath*:cms/mybatis/mapper/**/*.xml"));
return bean; return bean;
} }
@Bean(name = "youfoolTransactionManager") @Bean(name = "cmsTransactionManager")
public DataSourceTransactionManager transactionManager(@Qualifier("youfoolDS") DataSource dataSource) { public DataSourceTransactionManager transactionManager(@Qualifier("cmsDS") DataSource dataSource) {
return new DataSourceTransactionManager(dataSource); return new DataSourceTransactionManager(dataSource);
} }
@Bean(name = "youfoolSqlSessionTemplate") @Bean(name = "cmsSqlSessionTemplate")
public SqlSessionTemplate sqlSessionTemplate(@Qualifier("youfoolSqlSessionFactory") SqlSessionFactory sqlSessionFactory) { public SqlSessionTemplate sqlSessionTemplate(@Qualifier("cmsSqlSessionFactory") SqlSessionFactory sqlSessionFactory) {
return new SqlSessionTemplate(sqlSessionFactory); return new SqlSessionTemplate(sqlSessionFactory);
} }
} }

View File

@ -1,39 +0,0 @@
package com.chinaweal.youfool.prj.config;
import com.chinaweal.youfool.framework.springboot.filter.RepeatlyReadFilter;
import com.chinaweal.youfool.framework.springboot.log.filter.RestLogFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* @author itluck
*/
@Configuration
public class FilterConfig {
/**
* 日志记录过滤器
*/
@Bean
public FilterRegistrationBean<RestLogFilter> restLogFilter() {
FilterRegistrationBean<RestLogFilter> registrationBean = new FilterRegistrationBean<>();
registrationBean.setFilter(new RestLogFilter());
registrationBean.addUrlPatterns("/*");
registrationBean.setName("restLogFilter");
registrationBean.setOrder(-99);
return registrationBean;
}
/**
* 开启重复读取request流用于日志
*/
@Bean
public FilterRegistrationBean<RepeatlyReadFilter> repeatlyReadFilter() {
FilterRegistrationBean<RepeatlyReadFilter> registrationBean = new FilterRegistrationBean<>();
registrationBean.setFilter(new RepeatlyReadFilter());
registrationBean.addUrlPatterns("/*");
registrationBean.setName("repeatlyReadFilter");
registrationBean.setOrder(-100);
return registrationBean;
}
}

View File

@ -20,7 +20,7 @@ import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import javax.sql.DataSource; import javax.sql.DataSource;
/** /**
* 系统的数据源 * 项目的数据源
*/ */
@Configuration @Configuration

View File

@ -21,7 +21,7 @@ import java.util.Map;
/** /**
* shiro配置 * shiro配置
*/ */
@Configuration //@Configuration
public class ShiroConfig { public class ShiroConfig {
@Bean @Bean

View File

@ -1,27 +1,20 @@
package com.chinaweal.youfool.prj.config; package com.chinaweal.youfool.prj.config;
import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder; import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.ParameterBuilder;
import springfox.documentation.builders.PathSelectors; import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors; import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.schema.ModelRef;
import springfox.documentation.service.ApiInfo; import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact; import springfox.documentation.service.Contact;
import springfox.documentation.service.Parameter;
import springfox.documentation.spi.DocumentationType; import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket; import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2; import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
import java.util.ArrayList;
import java.util.List;
@Configuration @Configuration
@EnableSwagger2 @EnableSwagger2WebMvc
@EnableKnife4j
public class SwaggerKnife4j { public class SwaggerKnife4j {
@Value("${applicationName}") @Value("${applicationName}")
private String applicationName; private String applicationName;
@ -32,8 +25,8 @@ public class SwaggerKnife4j {
@Value("${license}") @Value("${license}")
private String license; private String license;
@Bean("youfool") @Bean("cms")
public Docket youfoolApi() { public Docket cmsApi() {
//添加head参数start //添加head参数start
return new Docket(DocumentationType.SWAGGER_2) return new Docket(DocumentationType.SWAGGER_2)
.enable(true) .enable(true)
@ -45,7 +38,6 @@ public class SwaggerKnife4j {
.build(); .build();
} }
private ApiInfo apiInfo() { private ApiInfo apiInfo() {
return new ApiInfoBuilder() return new ApiInfoBuilder()
.title(applicationName) .title(applicationName)
@ -57,4 +49,5 @@ public class SwaggerKnife4j {
.licenseUrl("https://www.chinaweal.com.cn") .licenseUrl("https://www.chinaweal.com.cn")
.build(); .build();
} }
} }

View File

@ -7,10 +7,10 @@ logging:
spring: spring:
datasource: datasource:
prj: prj:
url: jdbc:postgresql://172.22.80.157:5432/pms_dev url: jdbc:postgresql://172.22.80.157:5432/prj_template
username: postgres username: postgres
password: 123456 password: 123456
youfool: cms:
url: jdbc:postgresql://172.22.80.157:5432/pms_dev?currentSchema=youfool url: jdbc:postgresql://172.22.80.157:5432/prj_template?currentSchema=cms
username: postgres username: postgres
password: 123456 password: 123456

View File

@ -5,7 +5,7 @@ spring:
profiles: profiles:
active: dev active: dev
application: application:
name: prj-springboot-template name: youfool-prj-springboot-template
datasource: datasource:
#https://gitee.com/wenshao/druid/tree/master/druid-spring-boot-starter #https://gitee.com/wenshao/druid/tree/master/druid-spring-boot-starter
#https://github.com/alibaba/druid/wiki/DruidDataSource%E9%85%8D%E7%BD%AE #https://github.com/alibaba/druid/wiki/DruidDataSource%E9%85%8D%E7%BD%AE
@ -18,7 +18,7 @@ spring:
time-between-eviction-runs-millis: 60000 time-between-eviction-runs-millis: 60000
min-evictable-idle-time-millis: 300000 min-evictable-idle-time-millis: 300000
validation-query: select version() validation-query: select version()
youfool: cms:
filters: stat filters: stat
initial-size: 2 initial-size: 2
min-idle: 1 min-idle: 1
@ -53,7 +53,8 @@ jwt:
sm3: sm3:
secret: 82b0832fdaac473b83225ab92e7e3c3d secret: 82b0832fdaac473b83225ab92e7e3c3d
#knife4j: knife4j:
enable: true
# production: false # production: false
# basic: # basic:
# enable: true # enable: true