手动创建一个hello world,步骤如下:
1、创建maven项目


2、配置pom.xml

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.1.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
3、hello world,使用官方包名命名方式。

@Controller
@EnableAutoConfiguration
public class SampleController {
@RequestMapping("/")
@ResponseBody
String home() {
return "Hello World!";
}
public static void main(String[] args) throws Exception {
SpringApplication.run(SampleController.class, args);
}
}
4、启动,右键->run as ->java application

5、访问页面


6、参考资料
spring官方文档地址:
https://spring.io/projects/spring-framework
谷歌翻译地址:
https://translate.google.cn/
maven下载地址:
http://maven.apache.org/download.cgi
springbootGithub地址:
https://github.com/spring-projects/spring-boot
官方文档地址:
https://docs.spring.io/spring-boot/docs/2.1.0.BUILD-SNAPSHOT/reference/htmlsingle/#using-boot-using-the-default-package
网友评论