Spring Boot构建web项目01

发布时间 2023-09-12 22:13:23作者: 雨崩

配置:

破解版IDEA2019.3.3

Maven--3.6.3

java--1.8(8)

jdk--8

 

 

打开IDEA,new 一个 project,选择Spring Initializr

 

改写maven管理和java版本8

 

选择web项目

 

 

 

 

添加指定父级工程信息和java版本依赖

<modelVersion>4.0.0</modelVersion>

<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.1.6.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.example</groupId> <artifactId>demo</artifactId> <version>0.0.1-SNAPSHOT</version> <name>demo</name> <description>Demo project for Spring Boot</description> <properties> <java.version>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> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> </dependency> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter</artifactId> <version>RELEASE</version> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build>


</project>


 

创建一个入口类Application,注解,运行入口。

 

 

写一个Controller,并注解,指定路径和方法,

 

 

运行,

浏览器url输入

localhost:8080/path,回车