SpringBoot学习Demo

来源:互联网 发布:python def peven (n) 编辑:程序博客网 时间:2024/06/07 03:38

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