您的位置:首页 > 编程语言 > Java开发

SpringBoot学习Demo

2017-11-19 11:11 204 查看
SpringMVC配置文件整的崩溃,周末尝试一下SpringBoot

官网Demo:http://start.spring.io/

比较好的教程:https://www.cnblogs.com/ityouknow/p/5662753.html

项目结构就如官网demo

我是如此



不过SpringBoot默认html,jsp怕是需要再走一波配置,

完成以后,右键项目,run as application,启动,返回json很easy

坑在返回页面,需要加一个模板依赖,坑到半夜

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

<!-- Inherit defaults from Spring Boot -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.0.RELEASE</version>
</parent>

<!-- Add typical dependencies for a web application -->
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- 热启动配置 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<!-- 事务管理器,自动注入DataSourceTransactionManager -->
<!-- <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc</artifactId>
</dependency> -->
</dependencies>
<build>
<finalName>website</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<!-- 热启动配置 -->
<configuration>
<fork>true</fork>
</configuration>
</plugin>
</plugins>
</build>
<!-- 模板依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
慢慢养成一个习惯,写好demo就往码云扔,以后要用直接拖下来,贼方便
https://gitee.com/Damionew/spr.git
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: