.gitignore
@@ -4,9 +4,14 @@ .mtj.tmp/ # Package Files # *.iml *.jar *.war *.ear *.log .idea target # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* emergency/emergency-rpc-api/pom.xml
对比新文件 @@ -0,0 +1,76 @@ <?xml version="1.0" encoding="UTF-8"?> <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"> <parent> <artifactId>emergency</artifactId> <groupId>com.gkhy.safePlatfrom</groupId> <version>1.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <packaging>jar</packaging> <artifactId>emergency-rpc-api</artifactId> <distributionManagement> <!--稳定版本的仓库地址,必须是允许上传的私服地址--> <repository> <id>nexus-gkhy-releases</id> <url>http://121.239.169.27:28080/repository/guotai-release/</url> </repository> <!--开发版本的仓库地址,必须是允许上传的私服地址--> <snapshotRepository> <id>nexus-gkhy-snapshots</id> <url>http://121.239.169.27:28080/repository/guotai-snapshot/</url> </snapshotRepository> </distributionManagement> <build> <extensions> <extension> <groupId>kr.motd.maven</groupId> <artifactId>os-maven-plugin</artifactId> </extension> </extensions> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <version>3.3.0</version> <executions> <execution> <phase>generate-sources</phase> <goals> <goal>add-source</goal> </goals> <configuration> <sources> <source>src/main/java</source> <!-- <source>build/generated/source/proto/main/java</source>--> </sources> </configuration> </execution> </executions> </plugin> <!-- 上传源码 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> <version>3.2.1</version> <configuration> <attach>true</attach> </configuration> <executions> <execution> <phase>compile</phase> <goals> <goal>jar</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project> emergency/emergency-rpc-api/src/main/java/com/gkhy/safePlatform/emergency/rpc/api/EmergencyDemoRpcAPi.java
对比新文件 @@ -0,0 +1,8 @@ package com.gkhy.safePlatform.emergency.rpc.api; import com.gkhy.safePlatform.emergency.rpc.api.model.User; public interface EmergencyDemoRpcAPi { String sayHello(User user); } emergency/emergency-rpc-api/src/main/java/com/gkhy/safePlatform/emergency/rpc/api/model/User.java
对比新文件 @@ -0,0 +1,24 @@ package com.gkhy.safePlatform.emergency.rpc.api.model; public class User { private String name; private String email; public String getName() { return name; } public void setName(String name) { this.name = name; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } } emergency/emergency-rpc-provider/pom.xml
对比新文件 @@ -0,0 +1,23 @@ <?xml version="1.0" encoding="UTF-8"?> <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"> <parent> <artifactId>emergency</artifactId> <groupId>com.gkhy.safePlatfrom</groupId> <version>1.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <packaging>jar</packaging> <artifactId>emergency-rpc-provider</artifactId> <dependencies> <dependency> <groupId>com.gkhy.safePlatfrom</groupId> <artifactId>emergency-rpc-api</artifactId> </dependency> </dependencies> </project> emergency/emergency-rpc-provider/src/main/java/com/gkhy/safePlatform/emergency/rpc/provider/EmergencyDemoRpcProvider.java
对比新文件 @@ -0,0 +1,18 @@ package com.gkhy.safePlatform.emergency.rpc.provider; import com.gkhy.safePlatform.emergency.rpc.api.EmergencyDemoRpcAPi; import com.gkhy.safePlatform.emergency.rpc.api.model.User; import org.apache.dubbo.config.annotation.DubboService; @DubboService public class EmergencyDemoRpcProvider implements EmergencyDemoRpcAPi { @Override public String sayHello(User user) { if(user == null) return "non"; String resp = "Name: "+user.getName()+" Email:"+user.getEmail()+" rpc call"; return resp; } } emergency/emergency-service/pom.xml
对比新文件 @@ -0,0 +1,25 @@ <?xml version="1.0" encoding="UTF-8"?> <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"> <parent> <artifactId>emergency</artifactId> <groupId>com.gkhy.safePlatfrom</groupId> <version>1.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <packaging>jar</packaging> <artifactId>emergency-service</artifactId> <dependencies> <dependency> <groupId>com.gkhy.safePlatfrom</groupId> <artifactId>emergency-rpc-api</artifactId> <version>1.0-SNAPSHOT</version> </dependency> </dependencies> </project> emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/controller/Test.java
对比新文件 @@ -0,0 +1,26 @@ package com.gkhy.safePlatform.emergency.controller; import com.gkhy.safePlatform.account.rpc.apimodel.NameService; import org.apache.dubbo.config.annotation.DubboReference; import org.apache.log4j.LogManager; import org.apache.log4j.Logger; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("/emgc") public class Test { @DubboReference(check = false) private NameService nameService; // private Logger logger = LogManager.getLogger(Test.class); @RequestMapping(value = "/t/rpc",method = RequestMethod.GET) public Object testRpc(String id){ String resp = nameService.sayName(id); return resp; } } emergency/pom.xml
对比新文件 @@ -0,0 +1,21 @@ <?xml version="1.0" encoding="UTF-8"?> <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"> <parent> <artifactId>safe-platform</artifactId> <groupId>com.gkhy.safePlatfrom</groupId> <version>1.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>emergency</artifactId> <packaging>pom</packaging> <modules> <module>emergency-service</module> <module>emergency-rpc-api</module> <module>emergency-rpc-provider</module> </modules> </project> goal-manage/goal-manage-rpc-api/pom.xml
对比新文件 @@ -0,0 +1,77 @@ <?xml version="1.0" encoding="UTF-8"?> <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"> <parent> <artifactId>goal-manage</artifactId> <groupId>com.gkhy.safePlatfrom</groupId> <version>1.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <packaging>jar</packaging> <artifactId>goal-manage-rpc-api</artifactId> <distributionManagement> <!--稳定版本的仓库地址,必须是允许上传的私服地址--> <repository> <id>nexus-gkhy-releases</id> <url>http://121.239.169.27:28080/repository/guotai-release/</url> </repository> <!--开发版本的仓库地址,必须是允许上传的私服地址--> <snapshotRepository> <id>nexus-gkhy-snapshots</id> <url>http://121.239.169.27:28080/repository/guotai-snapshot/</url> </snapshotRepository> </distributionManagement> <build> <extensions> <extension> <groupId>kr.motd.maven</groupId> <artifactId>os-maven-plugin</artifactId> </extension> </extensions> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <version>3.3.0</version> <executions> <execution> <phase>generate-sources</phase> <goals> <goal>add-source</goal> </goals> <configuration> <sources> <source>src/main/java</source> <!-- <source>build/generated/source/proto/main/java</source>--> </sources> </configuration> </execution> </executions> </plugin> <!-- 上传源码 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> <version>3.2.1</version> <configuration> <attach>true</attach> </configuration> <executions> <execution> <phase>compile</phase> <goals> <goal>jar</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project> goal-manage/goal-manage-rpc-provider/pom.xml
对比新文件 @@ -0,0 +1,17 @@ <?xml version="1.0" encoding="UTF-8"?> <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"> <parent> <artifactId>goal-manage</artifactId> <groupId>com.gkhy.safePlatfrom</groupId> <version>1.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <packaging>jar</packaging> <artifactId>goal-manage-rpc-provider</artifactId> </project> goal-manage/goal-manage-service/pom.xml
对比新文件 @@ -0,0 +1,19 @@ <?xml version="1.0" encoding="UTF-8"?> <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"> <parent> <groupId>com.gkhy.safePlatfrom</groupId> <artifactId>goal-manage</artifactId> <version>1.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <packaging>jar</packaging> <artifactId>goal-manage-service</artifactId> </project> goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/goalManage/controller/DemoController.java
对比新文件 @@ -0,0 +1,20 @@ package com.gkhy.safePlatform.goalManage.controller; import com.gkhy.safePlatform.goalManage.service.DemoService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("/goal/demo") public class DemoController { @Autowired private DemoService demoService; @RequestMapping(value = "/test/rpc",method = RequestMethod.GET) public Object testRpc(String name,String email){ return demoService.getUserDescInfo(name,email); } } goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/goalManage/service/DemoService.java
对比新文件 @@ -0,0 +1,6 @@ package com.gkhy.safePlatform.goalManage.service; public interface DemoService { String getUserDescInfo(String name,String email); } goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/goalManage/service/impl/DemoServiceImpl.java
对比新文件 @@ -0,0 +1,22 @@ package com.gkhy.safePlatform.goalManage.service.impl; import com.gkhy.safePlatform.emergency.rpc.api.EmergencyDemoRpcAPi; import com.gkhy.safePlatform.emergency.rpc.api.model.User; import com.gkhy.safePlatform.goalManage.service.DemoService; import org.apache.dubbo.config.annotation.DubboReference; import org.springframework.stereotype.Service; @Service public class DemoServiceImpl implements DemoService { @DubboReference(check = false) private EmergencyDemoRpcAPi emergencyDemoRpcProvider; @Override public String getUserDescInfo(String name, String email) { User user = new User(); user.setName(name); user.setEmail(email); return emergencyDemoRpcProvider.sayHello(user); } } goal-manage/pom.xml
对比新文件 @@ -0,0 +1,28 @@ <?xml version="1.0" encoding="UTF-8"?> <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"> <parent> <artifactId>safe-platform</artifactId> <groupId>com.gkhy.safePlatfrom</groupId> <version>1.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>goal-manage</artifactId> <packaging>pom</packaging> <modules> <module>goal-manage-service</module> <module>goal-manage-rpc-api</module> <module>goal-manage-rpc-provider</module> </modules> <dependencies> <dependency> <groupId>com.gkhy.safePlatfrom</groupId> <artifactId>emergency-rpc-api</artifactId> </dependency> </dependencies> </project> pom.xml
对比新文件 @@ -0,0 +1,197 @@ <?xml version="1.0" encoding="UTF-8"?> <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> <groupId>com.gkhy.safePlatfrom</groupId> <artifactId>safe-platform</artifactId> <packaging>pom</packaging> <version>1.0-SNAPSHOT</version> <modules> <module>goal-manage/goal-manage-service</module> <module>goal-manage/goal-manage-rpc-provider</module> <module>emergency/emergency-service</module> <module>emergency/emergency-rpc-provider</module> <module>safePlatfrom-out-web</module> </modules> <properties> <project.build.sourceencoding>UTF-8</project.build.sourceencoding> <project.reporting.outputencoding>UTF-8</project.reporting.outputencoding> <java.version>1.8</java.version> <dubbo.version>3.0.8</dubbo.version> <nacos.client.version>2.1.0</nacos.client.version> <minio.version>8.4.2</minio.version> <okhttp.version>4.10.0</okhttp.version> <fastjson.version>1.2.47</fastjson.version> <mysql.connector.version>8.0.29</mysql.connector.version> <mybatisPlusStarter.version>3.5.1</mybatisPlusStarter.version> <guava.version>31.1-jre</guava.version> <account.rpc.model.version>1.0-SNAPSHOT</account.rpc.model.version> </properties> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.6.7</version> </parent> <dependencyManagement> <dependencies> <dependency> <groupId>org.apache.dubbo</groupId> <artifactId>dubbo-spring-boot-starter</artifactId> <version>${dubbo.version}</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>2.7.0</version> </dependency> <dependency> <groupId>com.alibaba.nacos</groupId> <artifactId>nacos-client</artifactId> <version>${nacos.client.version}</version> </dependency> <dependency> <groupId>org.apache.dubbo</groupId> <artifactId>dubbo-registry-nacos</artifactId> <version>${dubbo.version}</version> </dependency> <dependency> <groupId>io.minio</groupId> <artifactId>minio</artifactId> <version>${minio.version}</version> </dependency> <dependency> <groupId>com.squareup.okhttp3</groupId> <artifactId>okhttp</artifactId> <version>${okhttp.version}</version> </dependency> <!-- 安全平台组件 --> <dependency> <groupId>com.gkhy.safePlatfrom</groupId> <artifactId>account-rpc-api</artifactId> <version>${account.rpc.model.version}</version> </dependency> <dependency> <groupId>com.gkhy.safePlatfrom</groupId> <artifactId>emergency-rpc-api</artifactId> <version>1.0-SNAPSHOT</version> </dependency> </dependencies> </dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-logging</artifactId> </exclusion> <exclusion> <artifactId>logback-classic</artifactId> <groupId>ch.qos.logback</groupId> </exclusion> <!-- <exclusion>--> <!-- <groupId>org.springframework.boot</groupId>--> <!-- <artifactId>spring-boot-starter-tomcat</artifactId>--> <!-- </exclusion>--> </exclusions> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>${fastjson.version}</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-log4j2</artifactId> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>${mysql.connector.version}</version> </dependency> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>${mybatisPlusStarter.version}</version> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>1.9.9.1</version> <!-- <scope>runtime</scope>--> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid-spring-boot-starter</artifactId> <version>1.2.9</version> </dependency> <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>${guava.version}</version> </dependency> <dependency> <groupId>org.apache.dubbo</groupId> <artifactId>dubbo-spring-boot-starter</artifactId> </dependency> <dependency> <groupId>com.alibaba.nacos</groupId> <artifactId>nacos-client</artifactId> </dependency> <dependency> <groupId>org.apache.dubbo</groupId> <artifactId>dubbo-serialization-kryo</artifactId> <version>2.7.15</version> </dependency> <dependency> <groupId>org.apache.dubbo</groupId> <artifactId>dubbo-registry-nacos</artifactId> </dependency> <dependency> <groupId>io.minio</groupId> <artifactId>minio</artifactId> </dependency> <dependency> <groupId>com.squareup.okhttp3</groupId> <artifactId>okhttp</artifactId> </dependency> <!-- 安全平台业务组件 --> <dependency> <groupId>com.gkhy.safePlatfrom</groupId> <artifactId>account-rpc-api</artifactId> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.10.1</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build> </project> safePlatfrom-out-web/pom.xml
对比新文件 @@ -0,0 +1,62 @@ <?xml version="1.0" encoding="UTF-8"?> <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"> <parent> <artifactId>safe-platform</artifactId> <groupId>com.gkhy.safePlatfrom</groupId> <version>1.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>safePlatfrom-out-web</artifactId> <dependencies> <dependency> <groupId>com.gkhy.safePlatfrom</groupId> <artifactId>commons</artifactId> <version>1.0-SNAPSHOT</version> </dependency> <dependency> <groupId>com.gkhy.safePlatfrom</groupId> <artifactId>emergency-rpc-provider</artifactId> <version>1.0-SNAPSHOT</version> </dependency> <dependency> <groupId>com.gkhy.safePlatfrom</groupId> <artifactId>emergency-service</artifactId> <version>1.0-SNAPSHOT</version> </dependency> <dependency> <groupId>com.gkhy.safePlatfrom</groupId> <artifactId>goal-manage-service</artifactId> <version>1.0-SNAPSHOT</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <mainClass>com.gkhy.safePlatform.Application</mainClass> </configuration> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project> safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/Application.java
对比新文件 @@ -0,0 +1,13 @@ package com.gkhy.safePlatform; import org.apache.dubbo.config.spring.context.annotation.EnableDubbo; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication @EnableDubbo public class Application { public static void main(String[] agrs){ SpringApplication.run(Application.class,agrs); } } safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/database/DataSourceConfig.java
对比新文件 @@ -0,0 +1,40 @@ package com.gkhy.safePlatform.config.database; import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder; import com.baomidou.mybatisplus.annotation.DbType; import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import javax.sql.DataSource; @Configuration public class DataSourceConfig { @Bean @ConfigurationProperties("spring.datasource.one") DataSource dsOne(){ return DruidDataSourceBuilder.create().build(); } // @Bean // @ConfigurationProperties("spring.datasource.two") // DataSource dsTwo(){ // return DruidDataSourceBuilder.create().build(); // } /** * 新版分页插件 * @return */ @Bean public MybatisPlusInterceptor mybatisPlusInterceptor(){ MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); return interceptor; } } safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/database/MyBatisConfigOne.java
对比新文件 @@ -0,0 +1,60 @@ package com.gkhy.safePlatform.config.database; import com.alibaba.druid.pool.DruidDataSource; import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder; import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean; import org.apache.ibatis.plugin.Interceptor; import org.apache.ibatis.session.SqlSessionFactory; import org.mybatis.spring.SqlSessionTemplate; import org.mybatis.spring.annotation.MapperScan; import org.springframework.beans.factory.annotation.Autowired; 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.core.io.support.PathMatchingResourcePatternResolver; import org.springframework.core.io.support.ResourcePatternResolver; import org.springframework.stereotype.Repository; import javax.sql.DataSource; @Configuration @MapperScan(basePackages = "com.gkhy.safePlatform",sqlSessionTemplateRef = "sqlTemplate1",annotationClass = Repository.class) public class MyBatisConfigOne { @Autowired @Qualifier("dsOne") DataSource dsOne; @Autowired private MybatisPlusInterceptor mybatisPlusInterceptor; @Bean(name = "datasource1") @ConfigurationProperties(prefix = "spring.datasource.one") public DruidDataSource druidDataSourceA(){ return DruidDataSourceBuilder.create().build(); } @Bean(name = "sqlFactory1") public SqlSessionFactory sqlSessionFactory(@Qualifier("datasource1") DruidDataSource dataSource) throws Exception { MybatisSqlSessionFactoryBean factoryBean = new MybatisSqlSessionFactoryBean(); factoryBean.setDataSource(dataSource); ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); factoryBean.setMapperLocations(resolver.getResources("classpath*:config/mapper/**/**Mapper.xml")); //设置分页插件 Interceptor[] plugins = {mybatisPlusInterceptor}; factoryBean.setPlugins(plugins); return factoryBean.getObject(); } @Bean(name = "sqlTemplate1") public SqlSessionTemplate sqlSessionTemplate(@Qualifier("sqlFactory1") SqlSessionFactory sqlSessionFactory) { return new SqlSessionTemplate(sqlSessionFactory); } } safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/database/MybatisAspectj.java
对比新文件 @@ -0,0 +1,27 @@ package com.gkhy.safePlatform.config.database; import com.baomidou.mybatisplus.core.conditions.AbstractWrapper; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; import org.aspectj.lang.annotation.Pointcut; import org.springframework.stereotype.Component; @Aspect @Component public class MybatisAspectj { // 配置织入点 @Pointcut("execution(public * com.baomidou.mybatisplus.core.mapper.BaseMapper.selectOne(..))") public void selectOneAspect() { } @Before("selectOneAspect()") public void beforeSelect(JoinPoint point) { Object arg = point.getArgs()[0]; if (arg instanceof AbstractWrapper) { arg = (AbstractWrapper) arg; ((AbstractWrapper) arg).last("limit 1"); } } } safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/security/CorsConfig.java
对比新文件 @@ -0,0 +1,33 @@ package com.gkhy.safePlatform.config.security; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.cors.UrlBasedCorsConfigurationSource; import org.springframework.web.filter.CorsFilter; @Configuration public class CorsConfig { private CorsConfiguration buildConfig() { CorsConfiguration corsConfiguration = new CorsConfiguration(); // 你需要跨域的地址 注意这里的 127.0.0.1 != localhost // * 表示对所有的地址都可以访问 corsConfiguration.addAllowedOriginPattern("*"); // 1 // 跨域的请求方法 corsConfiguration.addAllowedMethod("*"); // 3 // 跨域的请求头 corsConfiguration.addAllowedHeader("*"); // 2 //加上了这一句,大致意思是可以携带 cookie //最终的结果是可以 在跨域请求的时候获取同一个 session corsConfiguration.setAllowCredentials(true); return corsConfiguration; } @Bean public CorsFilter corsFilter() { UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); //配置 可以访问的地址 source.registerCorsConfiguration("/**", buildConfig()); return new CorsFilter(source); } } safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/security/TokenAuthenticationFilter.java
对比新文件 @@ -0,0 +1,155 @@ //package com.gkhy.safePlatform.config.security; // //import com.alibaba.fastjson.JSONArray; //import com.alibaba.fastjson.JSONObject; //import com.gkhy.safePlatform.account.model.cache.CacheUser; //import com.gkhy.safePlatform.account.rpc.apimodel.NameService; //import com.gkhy.safePlatform.commons.config.token.TokenConfig; //import com.gkhy.safePlatform.commons.enums.RedisKeyEnum; //import com.gkhy.safePlatform.commons.enums.ResultCodes; //import com.gkhy.safePlatform.commons.exception.BusinessException; //import com.gkhy.safePlatform.commons.utils.RedisUtils; //import com.gkhy.safePlatform.commons.utils.StringUtils; //import com.gkhy.safePlatform.commons.vo.ResultVO; //import org.apache.dubbo.config.annotation.DubboReference; //import org.springframework.beans.factory.annotation.Autowired; //import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; //import org.springframework.security.core.GrantedAuthority; //import org.springframework.security.core.authority.SimpleGrantedAuthority; //import org.springframework.security.core.context.SecurityContextHolder; //import org.springframework.stereotype.Component; //import org.springframework.web.filter.OncePerRequestFilter; // //import javax.servlet.FilterChain; //import javax.servlet.ServletException; //import javax.servlet.http.HttpServletRequest; //import javax.servlet.http.HttpServletResponse; //import java.io.IOException; //import java.io.PrintWriter; //import java.util.ArrayList; //import java.util.List; // ///** //* @Description: token登录过滤器 //*/ //@Component //public class TokenAuthenticationFilter extends OncePerRequestFilter { // // @Autowired // private TokenConfig tokenConfig; // @Autowired // private RedisUtils redisUtil; // @DubboReference(check = false) // private NameService nameService; // // // // @Override // protected void doFilterInternal(HttpServletRequest req, HttpServletResponse resp, FilterChain chain) throws IOException, ServletException { // // try { // //获取当前认证成功用户权限信息 // UsernamePasswordAuthenticationToken authRequest = getAuthentication(req, resp); // if (authRequest != null) { // SecurityContextHolder.getContext().setAuthentication(authRequest); // } // // 执行下一个 filter 过滤器链 // chain.doFilter(req, resp); // } catch (BusinessException e) { // // 返回异常 // this.writeJSON(req, resp, new ResultVO<>(e.getError())); // } catch (Exception e) { // e.printStackTrace(); // this.writeJSON(req, resp, new ResultVO<>(ResultCodes.SERVER_ERROR)); // } // // // } // // // private UsernamePasswordAuthenticationToken getAuthentication(HttpServletRequest req,HttpServletResponse resp) { // // header获取token // String authToken = req.getHeader(tokenConfig.getHeader()); // String loginUserId = req.getHeader(tokenConfig.getLoginUserHeader()); // // if(authToken != null) { // // header 传入 userId // if (StringUtils.isBlank(loginUserId)) { // throw new BusinessException(ResultCodes.CLIENT_CREDENTIALS_LACK); // } // // 登录成功时,会将权限数据存入redis // // 这里是验证获取权限信息 // // 1.从redis中获取对应该用户的权限信息 // String accessTokenKey = RedisKeyEnum.authKey(RedisKeyEnum.AUTH_TOKEN, loginUserId); // Object o = redisUtil.get(accessTokenKey); // // 2.token是否存在 // if (o == null) { // // 是否存在 // throw new BusinessException(ResultCodes.CLIENT_CREDENTIALS_SIGN_INVALID); // }else{ // Long userId = Long.valueOf(loginUserId); // CacheUser cacheUser = JSONObject.parseObject(o.toString(), CacheUser.class); // assert userId.equals(cacheUser.getUserId()); // if ( !authToken.equals(cacheUser.getAccessToken())) { // throw new BusinessException(ResultCodes.CLIENT_CREDENTIALS_TOKEN_INVALID); // } // // // 3.redis获取权限 // String authoritiesKey = RedisKeyEnum.authKey(RedisKeyEnum.AUTH_AUTHORITIES, userId); // Object oo = redisUtil.get(authoritiesKey); // List<GrantedAuthority> authorities; // // 4.redis中是否存在 // if (oo != null) { // // 5.存在 // String json = oo.toString(); // authorities = JSONArray.parseArray(json, GrantedAuthority.class); // }else { // authorities = new ArrayList<>(); // // 6.不存在=>数据库查询 // List<String> roleCodes = nameService.getUserRoleCodeByUserId(userId); // // role // for (String roleCode : roleCodes) { // SimpleGrantedAuthority simpleGrantedAuthority = new SimpleGrantedAuthority("ROLE_" + roleCode); // authorities.add(simpleGrantedAuthority); // } // // // permission // List<String> permissions = nameService.getUserPermissionByUserId(userId); // for (String permission : permissions) { // SimpleGrantedAuthority simpleGrantedAuthority = new SimpleGrantedAuthority(permission); // authorities.add(simpleGrantedAuthority); // } // } // // // security对象中存入登陆者信息 // return new UsernamePasswordAuthenticationToken(userId,authToken,authorities); // // } // // // // // // // } // return null; // } // // // // protected void writeJSON(HttpServletRequest req, // HttpServletResponse resp, // ResultVO resultVO) throws IOException { // // 设置编码格式 // resp.setContentType("text/json;charset=utf-8"); // // 处理跨域问题 // resp.setHeader("Access-Control-Allow-Origin", "*"); // resp.setHeader("Access-Control-Allow-Methods", "POST, GET"); // // //输出JSON // PrintWriter out = resp.getWriter(); // out.write(JSONObject.toJSONString(resultVO)); // out.flush(); // out.close(); // } //} safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/security/WebSecurityConfig.java
对比新文件 @@ -0,0 +1,91 @@ package com.gkhy.safePlatform.config.security; import com.gkhy.safePlatform.account.rpc.apimodel.NameService; import com.gkhy.safePlatform.config.security.customzie.CustomizeAccessDeniedHandler; import com.gkhy.safePlatform.config.security.customzie.CustomizeAuthenticationEntryPoint; import org.apache.dubbo.config.annotation.DubboReference; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.builders.WebSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; import javax.annotation.Resource; @Configuration @EnableWebSecurity @EnableGlobalMethodSecurity(securedEnabled = true,prePostEnabled = true) public class WebSecurityConfig extends WebSecurityConfigurerAdapter { @Resource private CustomizeAccessDeniedHandler accessDeniedHandler; @Resource private CustomizeAuthenticationEntryPoint authenticationEntryPoint; // @Resource // private TokenAuthenticationFilter tokenAuthenticationFilter; @DubboReference(check = false) private NameService nameService; @Override protected void configure(HttpSecurity http) throws Exception { // 关闭跨域攻击 http.csrf().disable(); // 关闭session http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS); // 登录json放行 http.authorizeRequests().anyRequest().permitAll(); // 关闭 http.headers().cacheControl(); // jwt过滤器 // http.addFilterBefore(tokenAuthenticationFilter, UsernamePasswordAuthenticationFilter.class); // 没有登录,没有权限 => 自定义返回 http.exceptionHandling().authenticationEntryPoint(authenticationEntryPoint).accessDeniedHandler(accessDeniedHandler); // 请求认证访问 // http.authorizeRequests().anyRequest().authenticated(); // 允许跨域访问 http.cors(); } /** * @Description: 自定义查询逻辑 & 密码处理器 */ @Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { auth.userDetailsService(userDetailsService()); } /** * @Description: 自定义查询逻辑 */ @Bean @Qualifier("myUserDetailService") protected UserDetailsService userDetailsService(){ return username -> nameService.getUserDetailsByUsername(username); } @Override public void configure(WebSecurity web) { web.ignoring().mvcMatchers(); } } safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/security/customzie/CustomizeAccessDeniedHandler.java
对比新文件 @@ -0,0 +1,24 @@ package com.gkhy.safePlatform.config.security.customzie; import com.alibaba.fastjson.JSONObject; import com.gkhy.safePlatform.commons.enums.ResultCodes; import com.gkhy.safePlatform.commons.vo.ResultVO; import org.springframework.security.access.AccessDeniedException; import org.springframework.security.web.access.AccessDeniedHandler; import org.springframework.stereotype.Component; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; /** * 用来解决认证过的用户访问无权限资源时的异常 */ @Component public class CustomizeAccessDeniedHandler extends JSONAuthentication implements AccessDeniedHandler { @Override public void handle(HttpServletRequest req, HttpServletResponse resp, AccessDeniedException e) throws IOException { ResultVO result = new ResultVO<>(ResultCodes.CLIENT_PERMISSION_NOT_ALLOW); this.writeJSON(req,resp,JSONObject.toJSONString(result)); } } safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/security/customzie/CustomizeAuthenticationEntryPoint.java
对比新文件 @@ -0,0 +1,26 @@ package com.gkhy.safePlatform.config.security.customzie; import com.alibaba.fastjson.JSONObject; import com.gkhy.safePlatform.commons.enums.ResultCodes; import com.gkhy.safePlatform.commons.vo.ResultVO; import org.springframework.security.core.AuthenticationException; import org.springframework.security.web.AuthenticationEntryPoint; import org.springframework.stereotype.Component; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; /** * 用来解决匿名用户访问无权限资源时的异常 */ @Component public class CustomizeAuthenticationEntryPoint extends JSONAuthentication implements AuthenticationEntryPoint { @Override public void commence(HttpServletRequest req, HttpServletResponse resp, AuthenticationException e) throws IOException, ServletException { ResultVO result = new ResultVO<>(ResultCodes.CLIENT_PERMISSION_NOT_ALLOW); this.writeJSON(req,resp,JSONObject.toJSONString(result)); } } safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/security/customzie/JSONAuthentication.java
对比新文件 @@ -0,0 +1,26 @@ package com.gkhy.safePlatform.config.security.customzie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.PrintWriter; public abstract class JSONAuthentication { protected void writeJSON(HttpServletRequest req, HttpServletResponse resp, String content) throws IOException { // 设置编码格式 resp.setContentType("text/json;charset=utf-8"); // 处理跨域问题 resp.setHeader("Access-Control-Allow-Origin", "*"); resp.setHeader("Access-Control-Allow-Methods", "POST, GET"); //输出JSON PrintWriter out = resp.getWriter(); out.write(content); out.flush(); out.close(); } } safePlatfrom-out-web/src/main/resources/config/application-dev.yaml
对比新文件 @@ -0,0 +1,53 @@ server: tomcat: uri-encoding: UTF-8 basedir: / port: 8009 servlet: context-path: / # mysql spring: datasource: one: driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://twt.sinanoaq.com:13306/zhongtai.demo?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai username: root password: Sinanoaq#415 type: com.alibaba.druid.pool.DruidDataSource mybatis-plus: configuration: log-impl: org.apache.ibatis.logging.stdout.StdOutImpl dubbo: registry: protocol: nacos address: nacos://192.168.0.62:18848?namespace=e07a2454-136b-4498-99eb-09dae3336ebe&username=gkhy_safeplatform_out&password=9485uyJHISes09t application: name: gkhy-safeplatform-account-provider scan: # 扫描rpc接口定义包 base-packages: com.gkhy.safePlatform protocol: name: dubbo port: 18082 serialization: kryo consumer: # 服务连接超时时间 timeout: 3000 # 取消服务启动检查 check: false minio: endPoint: 192.168.0.62 port: 9001 accessKey: kH6eiQtNrWqGNb1r secretKey: ff5ykVUJJn0hi5PghsitdGNSsrW0Xrju secure: false bucketName: szh-stu urlPrefix: http://192.168.0.62/file safePlatfrom-out-web/src/main/resources/config/application-prod.yaml
对比新文件 @@ -0,0 +1,53 @@ server: tomcat: uri-encoding: UTF-8 basedir: / port: 8009 servlet: context-path: / # mysql spring: datasource: one: driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://twt.sinanoaq.com:13306/zhongtai.demo?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai username: root password: Sinanoaq#415 type: com.alibaba.druid.pool.DruidDataSource mybatis-plus: configuration: log-impl: org.apache.ibatis.logging.stdout.StdOutImpl dubbo: registry: protocol: nacos address: nacos://192.168.0.62:18848?namespace=71701971-5257-48d9-b745-a4218022b397&username=gkhy_safeplatform_out&password=9485uyJHISes09t application: name: gkhy-safeplatform-account-provider scan: # 扫描rpc接口定义包 base-packages: com.gkhy.safePlatform protocol: name: dubbo port: 18080 serialization: kryo consumer: # 服务连接超时时间 timeout: 3000 # 取消服务启动检查 check: false minio: endPoint: 192.168.0.62 port: 9001 accessKey: kH6eiQtNrWqGNb1r secretKey: ff5ykVUJJn0hi5PghsitdGNSsrW0Xrju secure: false bucketName: szh-stu urlPrefix: http://192.168.0.62/file safePlatfrom-out-web/src/main/resources/config/application-test.yaml
对比新文件 @@ -0,0 +1,53 @@ server: tomcat: uri-encoding: UTF-8 basedir: / port: 8009 servlet: context-path: / # mysql spring: datasource: one: driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://twt.sinanoaq.com:13306/zhongtai.demo?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai username: root password: Sinanoaq#415 type: com.alibaba.druid.pool.DruidDataSource mybatis-plus: configuration: log-impl: org.apache.ibatis.logging.stdout.StdOutImpl dubbo: registry: protocol: nacos address: nacos://192.168.0.62:18848?namespace=e07a2454-136b-4498-99eb-09dae3336ebe&username=gkhy_safeplatform_out&password=9485uyJHISes09t application: name: gkhy-safeplatform-account-provider scan: # 扫描rpc接口定义包 base-packages: com.gkhy.safePlatform protocol: name: dubbo port: 18080 serialization: kryo consumer: # 服务连接超时时间 timeout: 3000 # 取消服务启动检查 check: false minio: endPoint: 192.168.0.62 port: 9001 accessKey: kH6eiQtNrWqGNb1r secretKey: ff5ykVUJJn0hi5PghsitdGNSsrW0Xrju secure: false bucketName: szh-stu urlPrefix: http://192.168.0.62/file safePlatfrom-out-web/src/main/resources/config/application.yaml
对比新文件 @@ -0,0 +1,14 @@ spring: application: name: gkhy-safeplatform-out profiles: # active: prod active: dev mybatis-plus: mapper-locations: classpath:config/mapper/**/*.xml logging: config: classpath:config/log/log4j2.xml level: com.gkhy: info safePlatfrom-out-web/src/main/resources/config/log/log4j2.xml
对比新文件 @@ -0,0 +1,87 @@ <?xml version="1.0" encoding="utf-8"?> <!--status:log4j包内部日志等级 600s刷新一次配置 --> <Configuration status="OFF" monitorInterval="600"> <!-- 参数声明 --> <Properties> <!-- 日志文件存放根路径 --> <property name="DEFAULT_LOG_ROOT_PATH" value="./logs"/> <!-- 日志格式 --> <property name="LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} - %highlight{%-5level}{ERROR=Bright RED, WARN=Bright Yellow, INFO=Bright Green, DEBUG=Bright Cyan, TRACE=Bright White} %logger{36}.%M - %msg%n"/> <!-- 日志文件最大文件大小全局配置,单位可以为KB、MB或GB,一天之内最大文件产生数量全局配置 --> <property name="MAX_FILE_SIZE" value="100MB"/> <property name="MAX_FILE_NUM" value="30"/> <!-- debug 日志文件位置及名称,在rollFile的时候老文件的生成规则 --> <property name="DEBUG_FILE_PATH_ING" value="${DEFAULT_LOG_ROOT_PATH}/current/debug.log"/> <!-- filePattern="${LOG_HOME}/$${date:yyyy-MM}/${FILE_NAME}-%d{yyyy-MM-dd}-%i.log.gz"> 备份时使用gz格式压缩--> <property name="DEBUG_FILE_PATH_ED" value="${DEFAULT_LOG_ROOT_PATH}/history/$${date:yyyy-MM-dd}/debug-%d{yyyy-MM-dd}.%i.log"/> <!-- info 日志文件位置及名称,在rollFile的时候老文件的生成规则 --> <property name="INFO_FILE_PATH_ING" value="${DEFAULT_LOG_ROOT_PATH}/current/info.log"/> <property name="INFO_FILE_PATH_ED" value="${DEFAULT_LOG_ROOT_PATH}/history/$${date:yyyy-MM-dd}/info-%d{yyyy-MM-dd}.%i.log"/> <!-- error 日志文件位置及名称,在rollFile的时候老文件的生成规则 --> <property name="ERROR_FILE_PATH_ING" value="${DEFAULT_LOG_ROOT_PATH}/current/error.log"/> <property name="ERROR_FILE_PATH_ED" value="${DEFAULT_LOG_ROOT_PATH}/history/$${date:yyyy-MM-dd}/error-%d{yyyy-MM-dd}.%i.log"/> <!-- warn 日志文件位置及名称,在rollFile的时候老文件的生成规则 --> <property name="WARN_FILE_PATH_ING" value="${DEFAULT_LOG_ROOT_PATH}/current/warn_error.log"/> <property name="WARN_FILE_PATH_ED" value="${DEFAULT_LOG_ROOT_PATH}/history/$${date:yyyy-MM-dd}/warn_error-%d{yyyy-MM-dd}.%i.log"/> </Properties> <appenders> <!-- 控制台输出日志信息 --> <console name="Console_Log" target="SYSTEM_OUT"> <PatternLayout pattern="${LOG_PATTERN}"/> </console> <!-- debug日志文件输出日志信息 --> <RollingFile name="Debug_File" fileName="${DEBUG_FILE_PATH_ING}" filePattern="${DEBUG_FILE_PATH_ED}"> <ThresholdFilter level="DEBUG" onMatch="ACCEPT" onMismatch="DENY"/> <PatternLayout pattern="${LOG_PATTERN}"/> <Policies> <SizeBasedTriggeringPolicy size="${MAX_FILE_SIZE}"/> <TimeBasedTriggeringPolicy/> </Policies> <DefaultRolloverStrategy max="${MAX_FILE_NUM}"/> </RollingFile> <!-- info日志文件输出日志信息 --> <RollingFile name="Info_File" fileName="${INFO_FILE_PATH_ING}" filePattern="${INFO_FILE_PATH_ED}"> <ThresholdFilter level="INFO" onMatch="ACCEPT" onMismatch="DENY"/> <PatternLayout pattern="${LOG_PATTERN}"/> <Policies> <SizeBasedTriggeringPolicy size="${MAX_FILE_SIZE}"/> <TimeBasedTriggeringPolicy/> </Policies> <DefaultRolloverStrategy max="${MAX_FILE_NUM}"/> </RollingFile> <!-- warn日志文件输出日志信息 --> <RollingFile name="Warn_File" fileName="${ERROR_FILE_PATH_ING}" filePattern="${ERROR_FILE_PATH_ED}"> <ThresholdFilter level="WARN" onMatch="ACCEPT" onMismatch="DENY"/> <PatternLayout pattern="${LOG_PATTERN}"/> <Policies> <SizeBasedTriggeringPolicy size="${MAX_FILE_SIZE}"/> <TimeBasedTriggeringPolicy/> </Policies> <DefaultRolloverStrategy max="${MAX_FILE_NUM}"/> </RollingFile> <!-- error日志文件输出日志信息 --> <RollingFile name="Error_File" fileName="${ERROR_FILE_PATH_ING}" filePattern="${ERROR_FILE_PATH_ED}"> <ThresholdFilter level="ERROR" onMatch="ACCEPT" onMismatch="DENY"/> <PatternLayout pattern="${LOG_PATTERN}"/> <Policies> <SizeBasedTriggeringPolicy size="${MAX_FILE_SIZE}"/> <TimeBasedTriggeringPolicy/> </Policies> <DefaultRolloverStrategy max="${MAX_FILE_NUM}"/> </RollingFile> </appenders> <!--配置总的日志监听级别--> <loggers> <root level="INFO"> <appender-ref ref="Console_Log"/> <appender-ref ref="Debug_File"/> <appender-ref ref="Info_File"/> <appender-ref ref="Error_File"/> </root> </loggers> </Configuration>