Top

01,SpringBoot2 常用配置


server.port=8080

server.servlet.context-path=

spring.datasource.name=dataSource

spring.datasource.url=jdbc:mysql://localhost:3306/temp?useUnicode=true&characterEncoding=utf8&useSSL=false

spring.datasource.username=test

spring.datasource.password=a

spring.datasource.type=com.alibaba.druid.pool.DruidDataSource

spring.datasource.driver-class-name=com.mysql.jdbc.Driver

spring.datasource.druid.filters=stat

spring.datasource.druid.maxActive=20

spring.datasource.druid.initialSize=1

spring.datasource.druid.maxWait=60000

spring.datasource.druid.minIdle=1

spring.datasource.druid.timeBetweenEvictionRunsMillis=60000

spring.datasource.druid.minEvictableIdleTimeMillis=300000

spring.datasource.druid.validationQuery=select 1

spring.datasource.druid.testWhileIdle=true

spring.datasource.druid.testOnBorrow=false

spring.datasource.druid.testOnReturn=false

spring.datasource.druid.poolPreparedStatements=true

spring.datasource.druid.maxOpenPreparedStatements=20

spring.mvc.view.prefix=/

spring.mvc.view.suffix=.jsp

mybatis.mapper-locations=classpath:com/stu/mapper/xml/*.xml

mybatis.type-aliases-package=com.stu.pojo

pagehelper.helperDialect=mysql

pagehelper.reasonable=true

pagehelper.supportMethodsArguments=true

pagehelper.params=count=countSql


@SpringBootApplication

@MapperScan("com.test.mapper.itf")

@ComponentScan({ "com.test.controller", "com.test.biz.impl" })

@ServletComponentScan({ "com.test.listener" })

public class TestApplication {

   public static void main(String[] args) {

      SpringApplication.run(TestApplication.class, args);

   }

}


<?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.example</groupId>

   <artifactId>springboot2-demo</artifactId>

   <version>0.0.1-SNAPSHOT</version>

   <packaging>jar</packaging>


   <name>springboot2-demo</name>

   <description>Demo project for Spring Boot</description>


   <parent>

      <groupId>org.springframework.boot</groupId>

      <artifactId>spring-boot-starter-parent</artifactId>

      <version>2.0.3.RELEASE</version>

      <relativePath /> <!-- lookup parent from repository -->

   </parent>


   <properties>

      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

      <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

      <java.version>1.8</java.version>

   </properties>


   <dependencies>

      <dependency>

         <groupId>org.springframework.boot</groupId>

         <artifactId>spring-boot-starter-web</artifactId>

      </dependency>

      <dependency>

         <groupId>org.mybatis.spring.boot</groupId>

         <artifactId>mybatis-spring-boot-starter</artifactId>

         <version>1.3.2</version>

      </dependency>

      <dependency>

         <groupId>mysql</groupId>

         <artifactId>mysql-connector-java</artifactId>

         <scope>runtime</scope>

      </dependency>

      <dependency>

         <groupId>org.springframework.boot</groupId>

         <artifactId>spring-boot-starter-test</artifactId>

         <scope>test</scope>

      </dependency>


      <dependency>

         <groupId>com.alibaba</groupId>

         <artifactId>druid</artifactId>

         <version>1.1.14</version>

      </dependency>

      <dependency>

         <groupId>com.alibaba</groupId>

         <artifactId>druid-spring-boot-starter</artifactId>

         <version>1.1.14</version>

      </dependency>

      <dependency>

         <groupId>org.apache.tomcat.embed</groupId>

         <artifactId>tomcat-embed-jasper</artifactId>

      </dependency>

      <dependency>

         <groupId>org.apache.tomcat</groupId>

         <artifactId>tomcat-jsp-api</artifactId>

      </dependency>

   </dependencies>


   <build>

      <plugins>

         <plugin>

            <groupId>org.springframework.boot</groupId>

            <artifactId>spring-boot-maven-plugin</artifactId>

         </plugin>

      </plugins>

   </build>

</project>