springboot环境搭建
<?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>
<groupId>vip</groupId>
<artifactId>enjoy</artifactId>
<version>1.0-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.2.RELEASE</version>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
</project>
新建controller
@SpringBootApplication@ComponentScan(basePackages = "controller")
//@EnableAutoConfiguration
@RestController
public class App {
@RequestMapping("hello1")
Object get() {
return "hello1";
}
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
}
注意:
@EnableAutoConfiguration:
这个注解告诉Spring Boot根据添加的jar依赖猜测你想如何配置Spring。 由于spring-boot-starter-web添加了Tomcat和Spring MVC 所以auto-configuration将假定你正在开发一个web应用并相应地对Spring进行设置。
以上是 springboot环境搭建 的全部内容, 来源链接: utcz.com/z/516108.html