记录下spring boot配置信息,方便以后取用
maven相关配置信息,父项目配置
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<mybatis-spring-boot-starter.version>2.1.0</mybatis-spring-boot-starter.version>
<druid.version>1.1.13</druid.version>
<nacos.version>0.2.3</nacos.version>
<httpclient.version>4.5.7</httpclient.version>
<java.version>1.8</java.version>
<junit.version>4.12</junit.version>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.2.RELEASE</version>
<relativePath />
</parent>
<dependencies>
<!--spring boot -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>${mybatis-spring-boot-starter.version}</version>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>5.1.9</version>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.10</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-servlet-api</artifactId>
<version>8.0.53</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.alibaba.boot</groupId>
<artifactId>nacos-config-spring-boot-starter</artifactId>
<version>${nacos.version}</version>
</dependency>
<!-- quartz -->
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
</dependency>
<!--数据库 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>${druid.version}</version>
</dependency>
<!-- <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId>
<version>${druid.version}</version> </dependency> -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!-- common pool2 start -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
</dependency>
<!-- redis end -->
<!-- jackson start -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<!-- jackson end -->
<!-- httpclient start -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-vfs2</artifactId>
<version>2.0</version>
</dependency>
<!-- httpclient end -->
</dependencies>
<repositories>
<repository>
<id>apache</id>
<url>http://maven.apache.org</url>
</repository>
</repositories>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven
defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<!--解决异常:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)-->
<!--勿删-->
<resources>
<!--编译之后包含xml-->
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</build>
子项目打包配置
<build>
<finalName>yd-app</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<!-- 指定该Main Class为全局的唯一入口 -->
<mainClass>com.xxx.demo.app.start.Application</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal><!--可以把依赖的包都打包到生成的Jar包中-->
</goals>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<!--路径(如果只解决上边的问题,此处配置不需要) -->
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
<include>**/*.jpg</include>
<include>**/*.js</include>
<include>**/*.html</include>
<include>**/*.css</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
</build>
application.properties配置信息
server.port=9500
spring.application.name=PayManage
#====logback日志====
logging.config=classpath:logback-spring.xml
#====logback日志====
#===aop cglib
spring.aop.auto=true
spring.aop.proxy-target-class=true
#==== 数据库配置start=========
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/xxx?serverTimezone=Asia/Shanghai&useSSL=false&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true
spring.datasource.username=root
spring.datasource.password=xxxx
#durid settings
#初始化数量
spring.datasource.initialSize=10
#最大数量,当前连接池无效
spring.datasource.maxIdle=100
#最小数量
spring.datasource.minIdle=10
#最大活动数量
spring.datasource.maxActive=100
#每60秒运行一次空闲连接回收器
spring.datasource.timeBetweenEvictionRunsMillis=60000
#池中的连接空闲60分钟后被回收
spring.datasource.minEvictableIdleTimeMillis=3600000
#验证使用的SQL语句
spring.datasource.validationQuery=SELECT 1
#借出连接时不要测试,否则很影响性能
spring.datasource.testOnBorrow=false
#指明连接是否被空闲连接回收器(如果有)进行检验.如果检测失败,则连接将被从池中去除.
spring.datasource.testWhileIdle=true
#连接泄漏回收参数,当可用连接数少于3个时才执行
spring.datasource.removeAbandoned=3
#连接泄漏回收参数,180秒,泄露的连接可以被删除的超时值
spring.datasource.removeAbandoned=180
#==== 数据库配置end=======
#====redis start======
spring.redis.jedis.pool.max-active=200
spring.redis.jedis.pool.max-idle=50
spring.redis.jedis.pool.min-idle=10
spring.redis.jedis.pool.max-wait=2000
spring.redis.hostname = 127.0.0.1
spring.redis.port = 6379
spring.redis.timeout=30000
spring.redis.password = xxxx
spring.redis.database = 0
#====redis end======
#====JSP start=========
spring.mvc.static-path-pattern=/**
spring.resources.static-locations=/
spring.mvc.view.prefix=/jsp/
spring.mvc.view.suffix=.jsp
#====JSP end=========#======上传文件start=======
spring.http.multipart.enabled=true
spring.http.multipart.file-size-threshold=0
spring.servlet.multipart.max-request-size=512MB
spring.servlet.multipart.max-file-size=512MB
#======上传文件end=======
logback配置文件
<?xml version="1.0" encoding="UTF-8"?>
<!-- scan:当此属性设置为true时,配置文件如果发生改变,将会被重新加载,默认值为true。
scanPeriod:设置监测配置文件是否有修改的时间间隔,如果没有给出时间单位,默认单位是毫秒。当scan为true时,此属性生效。默认的时间间隔为1分钟。
debug:当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。 -->
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<!-- 上下文变量设置,用来定义变量值,其中name的值是变量的名称,value的值时变量定义的值。
通过<property>定义的值会被插入到logger上下文中。定义变量后,可以使“${}”来使用变量。 -->
<property name="CONTEXT_NAME" value="futures" />
<property name="logs.dir" value="${catalina.home}/logs" />
<!-- 上下文名称:<contextName>, 每个logger都关联到logger上下文,
默认上下文名称为“default”。但可以使用<contextName>设置成其他名字,用于区分不同应用程序的记录。
一旦设置,不能修改。 -->
<contextName>${CONTEXT_NAME}</contextName>
<!-- <appender>是<configuration>的子节点,是负责写日志的组件。
有两个必要属性name和class。
name指定appender名称,
class指定appender的实现类。 -->
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
<!-- 对日志进行格式化。 -->
<encoder>
<pattern>
%d{yyyy-MM-dd HH:mm:ss.SSS} - [%thread] - %level - [%replace(%caller{1}){'\t|Caller.{1}0|\r\n', ''}] - %msg%n
</pattern>
</encoder>
</appender>
<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 被写入的文件名,可以是相对目录,也可以是绝对目录,如果上级目录不存在会自动创建,没有默认值。 -->
<file>${logs.dir}/bank_api.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${logs.dir}/bank_api.%d{yyyy-MM-dd}.log</fileNamePattern>
</rollingPolicy>
<!-- 对记录事件进行格式化。 -->
<encoder>
<charset>UTF-8</charset>
<Pattern>
%d{yyyy-MM-dd HH:mm:ss.SSS} - [%thread] - %level - [%logger{80}:%line] - %msg%n
</Pattern>
</encoder>
</appender>
<!-- 用来设置某一个 包 或者具体的某一个 类 的日志打印级别、以及指定<appender>,
name:用来指定受此logger约束的某一个包或者具体的某一个类。
level:用来设置打印级别,大小写无关:TRACE, DEBUG, INFO, WARN, ERROR, ALL 和 OFF,还有一个特俗值INHERITED或者同义词NULL,代表强制执行上级的级别。如果未设置此属性,那么当前loger将会继承上级的级别。
additivity:是否向上级logger传递打印信息。默认是true。(这个logger的上级就是上面的root)
<logger>可以包含零个或多个<appender-ref>元素,标识这个appender将会添加到这个logger。-->
<logger name="com.xxx" level="DEBUG" additivity="true"></logger>
<logger name="org.apache.ibatis" level="INFO" additivity="true"></logger>
<!-- <logger name="org.mybatis" level="DEBUG" additivity="true"></logger> -->
<logger name="java.sql.Connection" level="INFO" additivity="true"></logger>
<logger name="java.sql.Statement" level="INFO" additivity="true"></logger>
<logger name="java.sql.PreparedStatement" level="INFO" additivity="true"></logger>
<logger name="java.sql.ResultSet" level="INFO" additivity="true"></logger>
<!-- 特殊的<logger>元素,是根logger。只有一个level属性,应为已经被命名为"root".
level:设置打印级别,大小写无关:TRACE, DEBUG, INFO, WARN, ERROR, ALL 和 OFF,不能设置为INHERITED或者同义词NULL。默认是DEBUG。
<root>可以包含零个或多个<appender-ref>元素,标识这个appender将会添加到这个loger。 -->
<root>
<level value="WARN" />
<appender-ref ref="file" />
<appender-ref ref="stdout" />
</root>
</configuration>