Skip to content

Commit b63d616

Browse files
author
yangjie
committed
升级springboot到1.4.0
1 parent 832f498 commit b63d616

File tree

5 files changed

+30
-37
lines changed

5 files changed

+30
-37
lines changed

pom.xml

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,74 +15,65 @@
1515
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1616
</properties>
1717

18-
<parent><!-- spring boot通用配置 -->
18+
<parent><!-- spring boot父级依赖, 定义了常用包的version -->
1919
<groupId>org.springframework.boot</groupId>
2020
<artifactId>spring-boot-starter-parent</artifactId>
21-
<version>1.2.7.RELEASE</version>
21+
<version>1.4.0.RELEASE</version>
2222
</parent>
2323

2424
<dependencies>
25-
26-
<dependency><!-- spring web通用配置 -->
25+
<dependency><!-- 核心starter, 包含自动配置/日志/yaml配置文件支持等 -->
26+
<groupId>org.springframework.boot</groupId>
27+
<artifactId>spring-boot-starter</artifactId>
28+
</dependency>
29+
<dependency><!-- web项目开发支持, 包含tomcat和springmvc等 -->
2730
<groupId>org.springframework.boot</groupId>
2831
<artifactId>spring-boot-starter-web</artifactId>
2932
</dependency>
30-
3133
<dependency><!-- 用于内嵌tomcat解析jsp -->
3234
<groupId>org.apache.tomcat.embed</groupId>
3335
<artifactId>tomcat-embed-jasper</artifactId>
3436
</dependency>
35-
3637
<dependency><!-- jsp中使用jstl -->
3738
<groupId>javax.servlet</groupId>
3839
<artifactId>jstl</artifactId>
3940
</dependency>
40-
4141
<dependency><!-- mysql驱动 -->
4242
<groupId>mysql</groupId>
4343
<artifactId>mysql-connector-java</artifactId>
4444
</dependency>
45-
4645
<dependency><!-- tomcat 连接池-->
4746
<groupId>org.apache.tomcat</groupId>
4847
<artifactId>tomcat-jdbc</artifactId>
4948
</dependency>
50-
5149
<dependency><!-- 使用spring声明式等 -->
5250
<groupId>org.springframework</groupId>
5351
<artifactId>spring-jdbc</artifactId>
5452
</dependency>
55-
5653
<dependency><!-- mybatis -->
5754
<groupId>org.mybatis</groupId>
5855
<artifactId>mybatis</artifactId>
5956
<version>3.3.0</version>
6057
</dependency>
61-
6258
<dependency><!-- spring操作mybatis插件 -->
6359
<groupId>org.mybatis</groupId>
6460
<artifactId>mybatis-spring</artifactId>
6561
<version>1.2.3</version>
6662
</dependency>
67-
68-
63+
6964
<dependency><!-- 用于spring测试 -->
7065
<groupId>org.springframework</groupId>
7166
<artifactId>spring-test</artifactId>
7267
<scope>test</scope>
7368
</dependency>
74-
7569
<dependency><!-- 用于单元测试 -->
7670
<groupId>junit</groupId>
7771
<artifactId>junit</artifactId>
7872
<scope>test</scope>
7973
</dependency>
80-
8174
</dependencies>
8275

83-
8476
<build>
85-
8677
<plugins>
8778
<plugin>
8879
<groupId>org.springframework.boot</groupId>
@@ -104,7 +95,6 @@
10495
</configuration>
10596
</plugin>
10697
</plugins>
107-
10898
</build>
10999

110100
</project>
Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
11
package org.yangjie;
22

3-
import org.apache.log4j.Logger;
3+
import org.slf4j.Logger;
4+
import org.slf4j.LoggerFactory;
45
import org.springframework.boot.SpringApplication;
5-
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
66
import org.springframework.boot.autoconfigure.SpringBootApplication;
7-
import org.yangjie.config.WebMvcConfig;
87

98
/**
109
* 程序入口, 启动器
10+
*
11+
* 此注解等同与以下三个注解:
12+
* @Configuration 此类为配置类
13+
* @ComponentScan 扫描当前目录下所有包
14+
* @EnableAutoConfiguration 开启根据依赖包进行自动配置
1115
*/
1216
@SpringBootApplication
13-
@EnableAutoConfiguration
1417
public class Application {
1518

16-
private static Logger logger = Logger.getLogger(Application.class);
19+
private static Logger logger = LoggerFactory.getLogger(Application.class);
1720

18-
1921
public static void main(String[] args) {
20-
21-
SpringApplication.run(WebMvcConfig.class, args);
22-
22+
SpringApplication.run(Application.class, args);
2323
logger.info("server is running...");
24-
2524
}
2625

2726
}
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
package org.yangjie.config;
22

3-
import org.springframework.context.annotation.ComponentScan;
43
import org.springframework.context.annotation.Configuration;
4+
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
55
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
66

77
@Configuration
8-
@ComponentScan("org.yangjie")
98
public class WebMvcConfig extends WebMvcConfigurerAdapter {
9+
10+
@Override // 默认首页
11+
public void addViewControllers(ViewControllerRegistry registry) {
12+
registry.addViewController("/").setViewName("/login.jsp");
13+
}
1014

1115
}

src/main/resources/application.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
##服务配置
2+
server:
3+
port: 8080
4+
5+
16
##数据库配置
27
dataSource:
38
driverClassName: com.mysql.jdbc.Driver
@@ -14,9 +19,6 @@ dataSource:
1419
removeAbandoned: true ##是否进行无用链接回收, 默认: false
1520
removeAbandonedTimeout: 60 ##链接有效期,超时将被回收(秒), 默认: 60
1621

17-
##服务配置
18-
server:
19-
port: 8080
2022

2123
##日志配置
2224
logging:

src/test/java/org/yangjie/BaseTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,16 @@
22

33
import org.junit.runner.RunWith;
44
import org.springframework.beans.factory.annotation.Autowired;
5-
import org.springframework.boot.test.SpringApplicationConfiguration;
65
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
76
import org.springframework.test.context.web.WebAppConfiguration;
8-
import org.springframework.web.context.WebApplicationContext;
9-
import org.yangjie.config.WebMvcConfig;;
7+
import org.springframework.web.context.WebApplicationContext;;
108

119
/**
1210
* Junit测试基类
1311
*/
1412
@WebAppConfiguration
1513
@RunWith(SpringJUnit4ClassRunner.class)
16-
@SpringApplicationConfiguration(classes = WebMvcConfig.class)
14+
//@SpringApplicationConfiguration(classes = WebMvcConfig.class)
1715
public class BaseTest{
1816

1917
@Autowired

0 commit comments

Comments
 (0)