Spring Boot入门初体验(1)--Maven建立Spring Boot项目(超详细)

Spring Boot好处

  1. Spring Boot使编码变简单
  2. Spring Boot使配置变简单
  3. Spring Boot使部署变简单
  4. Spring Boot使监控变简单

建立Maven项目

步骤:IDE点击 NEW -> Maven Project -> Next

在filter中输入web或webapp 选择 maven-archetype-webapp

设置包名(Group Id)与项目名(Artifact Id),点击finish完成项目建立
web

Spring Boot Hello World

1.pom.xml中添加web支持模块spring

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.9.RELEASE</version>
</parent>

 <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
 </dependency>

2.编写Spring Boot启动类

3.编写HelloController

4.运行主程序测试
在main主函数入口右键Run as,选择Java Applicationapp

maven运行Spring Boot:选择项目 Run as -> Maven Build
webapp

访问项目不用添加项目名
如:http://localhost:8080/hello
不然会出现Web Error Pagemaven

相关文章
相关标签/搜索