1.开发环境
开发工具:IDEA2018.2.1
JDK:1.9
Maven : 3.3.9
操作系统:window 7 / window 10
2.项目结构
3.详细步骤和说明
3.1 使用IDEA新建Maven空白项目
file->new->project,然后按照要求填好。如下:
点击finsh后会生成项目如下:
3.2 在pom.xml文件添加继承、依赖和插件配置
<!-- 默认继承 --> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> <version>2.0.5.RELEASE</version> </parent>
<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies>
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build>
3.3 在com.azxx.springstudy.demon新建HelloWorld.java 并添加注解
@RestController @EnableAutoConfiguration public class HelloWorld { @RequestMapping("/") String helloworld(){ return "Hello World!"; } public static void main(String[] args) { SpringApplication.run(HelloWorld.class,args); } }
3.3 运行main方法,并打开localhost:8080。HelloWorld就完成了。