企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持知识库和私有化部署方案 广告
- 1.通过IDEA或者Eclipse的spring Initialize创建 ![](https://box.kancloud.cn/7868c783faed7f3179d820de0a1cf85b_813x688.png) ![](https://box.kancloud.cn/445178af4ce3ccb4e3ef027c5a053812_322x129.png) 在src/main\com.example.demo编写controller ~~~ @Controller public class HelloController { @RequestMapping("/hello") @ResponseBody public String helloPage(){ return "hello springboot"; } } ~~~ - 2.访问http://start.spring.io/创建springboot的骨架 ![](https://box.kancloud.cn/06843111da005f85444d0d4b0dd73b64_1298x505.png) ![](https://box.kancloud.cn/c5f92488e2368578c5ca8306a3dd3e00_1132x250.png) 然后通过import导入到IDEA中 ![](https://box.kancloud.cn/15ec9769afdfd80f3be7d68cc2bc4c73_440x151.png) - 3.自己手动搭建 ![](https://box.kancloud.cn/bc8696ff0d611516d58ffef7ba047671_816x703.png) ![](https://box.kancloud.cn/8706b3d6fda5ebf190e9acb1c6206c0d_807x131.png) ![](https://box.kancloud.cn/2a297422d8f57b6644ecc5bdafd83a01_809x66.png) 1.配置pom文件 ~~~ //pom.xml <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.1.1.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <properties> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies> ~~~ 2.编写控制器Controller ~~~ @Controller public class HelloController { @RequestMapping("/hello") @ResponseBody public String helloPage(){ return "Spring3"; } } ~~~ 3.编写配置类 ~~~ //AppConfig类 @SpringBootApplication public class AppConfig { public static void main(String[] args) { SpringApplication.run(AppConfig.class,args); } } ~~~ 4.运行main方法,浏览器访问:http://localhost:8080/hello