spring boot 起步
新建工程
生成的maven工程
pom.xml文件
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
HelloWorldController
@RestController
@EnableAutoConfiguration
public class HelloWorldController {
@RequestMapping("/hello")
public String hello(){
return "hello spring boot";
}
}
项目启动
运行DemoApplication.java
中的main
方法就行:
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
访问
http://localhost:8080/hello