Skip to content

Commit

Permalink
增加不同环境配置
Browse files Browse the repository at this point in the history
  • Loading branch information
abel533 committed Sep 6, 2017
1 parent 8151101 commit 201879e
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 13 deletions.
11 changes: 10 additions & 1 deletion src/main/java/tk/mybatis/springboot/Application.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package tk.mybatis.springboot;

import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.stereotype.Controller;
Expand All @@ -16,12 +19,18 @@
@EnableWebMvc
@SpringBootApplication
@MapperScan(basePackages = "tk.mybatis.springboot.mapper")
public class Application extends WebMvcConfigurerAdapter {
public class Application extends WebMvcConfigurerAdapter implements CommandLineRunner {
private Logger logger = LoggerFactory.getLogger(Application.class);

public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}

@Override
public void run(String... args) throws Exception {
logger.info("服务启动完成!");
}

@RequestMapping("/")
String home() {
return "redirect:countries";
Expand Down
13 changes: 13 additions & 0 deletions src/main/resources/application-dev.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
server.port=9090
debug=true
logging.level.root=debug
logging.level.tk.mybatis.springboot.mapper=trace
spring.datasource.url=jdbc:mysql://localhost:3306/test
spring.datasource.username=root
spring.datasource.password=
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.druid.initial-size=1
spring.datasource.druid.min-idle=1
spring.datasource.druid.max-active=20
spring.datasource.druid.test-on-borrow=true
spring.datasource.druid.stat-view-servlet.allow=true
11 changes: 11 additions & 0 deletions src/main/resources/application-production.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
server.port=8080
logging.level.root=info
spring.datasource.url=jdbc:mysql://localhost:3306/test
spring.datasource.username=root
spring.datasource.password=
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.druid.initial-size=1
spring.datasource.druid.min-idle=1
spring.datasource.druid.max-active=20
spring.datasource.druid.test-on-borrow=true
spring.datasource.druid.stat-view-servlet.allow=true
19 changes: 7 additions & 12 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
server.port=9090
logging.level.tk.mybatis=TRACE
spring.datasource.url=jdbc:mysql://localhost:3306/test
spring.datasource.username=root
spring.datasource.password=
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.druid.initial-size=1
spring.datasource.druid.min-idle=1
spring.datasource.druid.max-active=20
spring.datasource.druid.test-on-borrow=true
spring.datasource.druid.stat-view-servlet.allow=true

# \u8BBE\u7F6E\u6FC0\u6D3B\u7684\u73AF\u5883
spring.profiles.active=dev
# \u89C6\u56FE\u76F8\u5173
spring.mvc.view.prefix=/templates/
spring.mvc.view.suffix=.ftl

spring.freemarker.cache=false
spring.freemarker.request-context-attribute=request
# mybatis \u914D\u7F6E
mybatis.type-aliases-package=tk.mybatis.springboot.model
mybatis.mapper-locations=classpath:mapper/*.xml
# \u901A\u7528 Mapper \u914D\u7F6E
mapper.mappers=tk.mybatis.springboot.util.MyMapper
mapper.not-empty=false
mapper.identity=MYSQL
# \u5206\u9875\u63D2\u4EF6\u914D\u7F6E
pagehelper.helperDialect=mysql
pagehelper.reasonable=true
pagehelper.supportMethodsArguments=true
Expand Down

0 comments on commit 201879e

Please sign in to comment.