SpringBoot入门
2020-04-15 本文已影响0人
帅气的阿斌
创建springboot工程方式一手动设置pom.xml
pom.xml文件配置
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.1.RELEASE</version>
</parent>
<groupId>org.example</groupId>
<artifactId>springbootstart</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>13</java.version>
<maven.compiler.source>13</maven.compiler.source>
<maven.compiler.target>13</maven.compiler.target>
<encoding>UTF-8</encoding>
</properties>
<dependencies>
<!-- web功能-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.2.1.RELEASE</version>
</dependency>
<!-- 热部署-->
<!-- (1)File-Settings-Compiler-Build Project automatically-->
<!-- (2)ctrl + shift + alt + /(windows) shift + option + command(mac)-->
<!--选择Registry,勾上 Compiler autoMake allow when app running–>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
</dependencies>
</project>
代码实现
引导类
@SpringBootApplication
public class SpringBootApp {
public static void main(String[] args) {
SpringApplication.run(SpringBootApp.class);
}
}
快速创建接口
@Controller
public class QuickController {
@RequestMapping("/quickstart")
@ResponseBody
public String quick(){
return "hehehheheheh";
}
}
热部署
<!-- 热部署-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
创建springboot工程方式二使用向导创建springboot工程
Spring Initializr->........