简介
spring boot 它的设计目的就是为例简化开发,开启了各种自动装配,你不想写各种配置文件,引入相关的依赖就能迅速搭建起一个web工程。它采用的是建立生产就绪的应用程序观点,优先于配置的惯例。
可能你有很多理由不放弃SSM,SSH,但是当你一旦使用了springboot ,你会觉得一切变得简单了,配置变的简单了、编码变的简单了,部署变的简单了,感觉自己健步如飞,开发速度大大提高了。就好比,当你用了IDEA,你会觉得再也回不到Eclipse时代一样。另,本系列教程全部用的IDEA作为开发工具。
建构工程
你需要:
- 15分钟
- jdk 1.8或以上
- maven 3.0+
- Idea
打开Idea-> new Project ->Spring Initializr ->填写group、artifact ->钩上web(开启web功能)->点下一步就行了。
pom依赖如下:
1 <?xml version="1.0" encoding="UTF-8"?> 2 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 3 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4 <modelVersion>4.0.0</modelVersion> 5 6 <groupId>com.asideal</groupId> 7 <artifactId>zhcx</artifactId> 8 <version>0.0.1-SNAPSHOT</version> 9 <packaging>war</packaging> 10 11 <name>zhcx</name> 12 <description>Demo project for Spring Boot</description> 13 14 <parent> 15 <groupId>org.springframework.boot</groupId> 16 <artifactId>spring-boot-starter-parent</artifactId> 17 <version>2.0.4.RELEASE</version> 18 <relativePath/> <!-- lookup parent from repository --> 19 </parent> 20 21 <properties> 22 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 23 <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> 24 <java.version>1.8</java.version> 25 </properties> 26 27 <dependencies> 28 <dependency> 29 <groupId>org.springframework.boot</groupId> 30 <artifactId>spring-boot-starter-web</artifactId> 31 </dependency> 32 33 <dependency> 34 <groupId>org.springframework.boot</groupId> 35 <artifactId>spring-boot-starter-test</artifactId> 36 <scope>test</scope> 37 </dependency> 38 39 <!-- springboot使用jsp模版的依赖 --> 40 <dependency> 41 <groupId>org.apache.tomcat.embed</groupId> 42 <artifactId>tomcat-embed-jasper</artifactId> 43 <scope>provided</scope> 44 </dependency> 45 <dependency> 46 <groupId>javax.servlet</groupId> 47 <artifactId>jstl</artifactId> 48 </dependency> 49 50 <!-- 修改类不需要重启的依赖 --> 51 <!-- 热部署模块 --> 52 <dependency> 53 <groupId>org.springframework.boot</groupId> 54 <artifactId>spring-boot-devtools</artifactId> 55 <optional>true</optional> <!-- 这个需要为 true 热部署才有效 --> 56 </dependency> 57 58 <!-- webjars支持 --> 59 <dependency> 60 <groupId>org.webjars</groupId> 61 <artifactId>jquery</artifactId> 62 <version>2.1.4</version> 63 </dependency> 64 <dependency> 65 <groupId>org.webjars</groupId> 66 <artifactId>webjars-locator</artifactId> 67 <version>0.32-1</version> 68 </dependency> 69 70 <!-- mysql支持 --> 71 <!-- MYSQL --> 72 <dependency> 73 <groupId>mysql</groupId> 74 <artifactId>mysql-connector-java</artifactId> 75 </dependency> 76 <!-- Spring Boot JDBC --> 77 <dependency> 78 <groupId>org.springframework.boot</groupId> 79 <artifactId>spring-boot-starter-jdbc</artifactId> 80 </dependency> 81 82 <!-- Json包 --> 83 <dependency> 84 <groupId>com.alibaba</groupId> 85 <artifactId>fastjson</artifactId> 86 <version>1.2.16</version> 87 </dependency> 88 89 <!-- druid为了监控数据库 --> 90 <dependency> 91 <groupId>com.alibaba</groupId> 92 <artifactId>druid</artifactId> 93 <version>1.0.25</version> 94 </dependency> 95 96 97 </dependencies> 98 99 <build> 100 <plugins> 101 <plugin> 102 <groupId>org.springframework.boot</groupId> 103 <artifactId>spring-boot-maven-plugin</artifactId> 104 </plugin> 105 </plugins> 106 </build> 107 108 109 </project>
项目目录结构: