SpringBoot系统搭建集成-001-工程构建建
Lison <cundream@163.com>, v1.0.0, 2019.10.13SpringBoot系统搭建集成-001-工程构建建工程搭建使用搭建工具:JDK1.8MavenIDEA打开idea,新建一个project,然后右键工程,新建一个module,选择Spring Initializr然后next,填写group、artifact ,然后next...
·
Lison <cundream@163.com>, v1.0.0, 2019.10.13
SpringBoot系统搭建集成-001-工程构建建
工程搭建
使用搭建工具:
- JDK1.8
- Maven
- IDEA
打开idea,新建一个project,然后右键工程,新建一个module,选择Spring Initializr
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Pw7jNXx7-1572488033713)(....\springboot\typora-user-images\1571104796490.png)]](https://i-blog.csdnimg.cn/blog_migrate/7c860eda622c1a617c222563c52ae273.png)
然后next,填写group、artifact ,然后next,
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Gus4Wj8B-1572488011019)(....\springboot\typora-user-images\1571105228378.png)]](https://i-blog.csdnimg.cn/blog_migrate/7d0d399a8689f23058934bce123e91d6.png)
选择web,next完成工程创建
工程目录如下:
- src
-main
-java
-package
-SpringbootApplication
-resouces
- statics
- templates
- application.properties
-test
- pom
pom文件如下 :
<?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>com.springcloud</groupId>
<artifactId>springboot</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>springboot</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<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>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
修改程序入口类如下:
/**
* @author Lison
*/
@SpringBootApplication
public class SpringbootbuildingApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(SpringbootbuildingApplication.class);
}
public static void main(String[] args) {
SpringApplication.run(SpringbootbuildingApplication.class, args);
}
}
修改配置文件如下:
# Server settings (ServerProperties)
#端口
server.port=8082
server.address=127.0.0.1
#server.sessionTimeout=30
#访问路径名称
server.contextPath=/bootbuliding
新建一个test.controller包,新建一个web类:
/**
* @author : Lison
* @Date: 2019/10/15 10:25
* @Description: 测试web
*/
@RestController
public class TestController {
@RequestMapping(value = "/hello",method = RequestMethod.GET)
public String hello(){
return "hello Spring boot";
}
}
运行程序看控制台
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-MNPyAcor-1572488011021)(....\springboot\typora-user-images\1571106722317.png)]](https://i-blog.csdnimg.cn/blog_migrate/5fb35c69ce4099dcc6537fc625d80477.png)
说明程序启动成功了。
然后浏览器访问:http://127.0.0.1:8082/bootbuliding/hello
响应结果
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Ry1KCO0t-1572488011022)(....\springboot\typora-user-images\1571107255376.png)]](https://i-blog.csdnimg.cn/blog_migrate/4886aec75f0171c51f2e4ce2739cb3bc.png)
更多推荐



所有评论(0)