1、创建一个简单的maven project项目
2、下面来看一下项目结构:
3、pom.xml 配置jar包
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.9.RELEASE</version> <relativePath/> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies>
pom.xml
4、创建一个SpringBoot项目运行的启动类
package com.cppdy; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } }
Application
5、创建一个controller
package com.cppdy.controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class HelloWordController { @RequestMapping("hello") public String hello() { return "HelloWord"; } }
HelloWordController
6、到这一步项目就配置好了打开浏览器输入就可以访问了,请注意访问不需要加项目名,如果要加需要在application.properties文件中另行配置
原文地址:https://www.cnblogs.com/cppdy/p/10005239.html
时间: 2024-11-04 12:02:40