springboot2.0

springboot2.0  快速开发框架 

优点:快速开发,开箱即用,简化spring配置,启动方便维护方便

1.第一个WEB  (和1.5有差别)

(1)pom.xml

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.7.RELEASE</version>
<relativePath />
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>

(2)只要一个hellocontroller,不用app类,启动方式的不同。

@RestController
@EnableAutoConfiguration
public class helloController {

@RequestMapping("/hello")
public String hello(){
return "呵";
}
public static void main(String[] args) {
SpringApplication.run(helloController.class, args);
}

2.集成freeMarker前端模版(1.5中是Thymelea模版,主要是导入包不同而已 ),以前是MODEDIVE

(1)导包

<!-- 引入freeMarker的依赖包. --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-freemarker</artifactId> </dependency>

(2)application.yml 中配置    ( http://toyaml.com 转化为yml格式的网站工具)

(3)创建index.ftl

<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8" /> <title></title> </head> <body> </body> </html>

(4)controller类/index     reutrn "index";

3.springboot集成JSP

不推荐使用

4.集成JPA

(未完)

5.集成Mybatis

在res资源下建立mapping,xml  来配置。而在MAPPER类中就不用写@select这些语句。

猜你喜欢

转载自www.cnblogs.com/StingLon/p/10515309.html