IDEA创建SpringBoot项目简单实例
2019-03-16 22:51
435 查看
版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/liaoyou11115/article/details/88607765
废话不多说,直接上图:
我们来新建一个Controller类(这里注意Controller类要放在DemoApplication的下一级目录):
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("index") public class IndexController { @GetMapping("view") public String showView() { return "Hello Spring"; } }
pom.xml配置:
<?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> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.1.3.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>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>
然后就可以启动项目:
访问,默认是8080端口:
相关文章推荐
- IDEA + Gradle + Springboot Web + Mybatis项目实例创建
- IDEA-------(二)快速创建一个简单的Spring boot项目
- 初学springboot+Mybatis+MySQL+idea创建简单项目
- Idea简单创建一个springboot的maven项目
- 使用IDEA创建Spring Boot项目, 整合Mybatis ,连接MySql数据库,实现简单的登录注册功能
- IDEA 创建spring boot项目时没有web.xml
- idea创建springboot项目图文教程(配置文件)(五)
- SpringBoot系列(二):创建一个简单的SpringBoot项目
- 快速创建springboot项目:使用http://start.spring.io/网页创建,使用IDEA的Spring Initializr创建,使用SpringBoot CLI创建
- SprigBoot(三)创建一个简单的SpringBootWeb项目
- 创建一个简单的SpringBoot项目
- Eclipse创建简单的spring boot项目
- IDEA创建基于springboot的多个module聚合项目,并生成war包
- IDEA下gradle创建springboot项目
- 如何用IDEA创建第一个Spring Boot项目
- idea快速创建springboot项目
- (一)IDEA快速创建Springboot项目
- 使用IDEA搭建一个简单的SpringBoot项目——详细过程
- 创建简单的Springboot项目
- Spring Boot学习与进阶-1.创建Spring Boot项目(IDEA)