使⽤idea⾃带的springInitializer搭建SpringBoot流程(习惯优于配置)
1.打开idea,选择create new project
2.jdk版本使⽤1.8以上的版本
3.
4.选择web提供web⽀持
5.
6.点击Finish,等待idea帮你搭建环境
7.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="/POM/4.0.0" xmlns:xsi="/2001/XMLSchema-instance" xsi:schemaLocation="/POM/4.0.0 /xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.kudesoft</groupId>
<artifactId>myspringboottwo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>myspringboottwo</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<!--增加web⽀持-->
<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>
8.写⼀个控制器类
@Controller
public class MyController {
idea debug@RequestMapping("/out")
@ResponseBody
public String test(){
return "success";
}
}
9.启动⼊⼝类
10.启动成功
11.在浏览器地址栏输⼊localhost:8080/out
到这⾥springboot环境已经搭建完成,⽽且能成功运⾏!
@Controller
public class MyController {
@RequestMapping("/out")
@ResponseBody
public String test(){
return "success";
}
}
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论