springboot的helloworld
来源:互联网 发布:python tts 引擎 编辑:程序博客网 时间:2024/06/14 18:26
//pom.xml//在pom.xml中引入spring-boot-start-parent,spring官方的解释叫什么stater poms,它可以提供dependency management,也就是说依赖管理,引入以后在申明其它dependency的时候就不需要version了,<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.6.RELEASE</version></parent>开发的是web工程,所以需要在pom.xml中引入spring-boot-starter-web,spring官方解释说spring-boot-start-web包含了spring webmvc和tomcat等web开发的特性。<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency></dependencies>如果我们要直接Main启动spring,那么以下plugin必须要添加,否则是无法启动的。如果使用maven 的spring-boot:run的话是不需要此配置的。(我在测试的时候,如果不配置下面的plugin也是直接在Main中运行的。)<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin </artifactId> </plugin> </plugins></build>
java代码
@SpringBootApplication申明让spring boot自动给程序进行必要的配置,等价于以默认属性使用@Configuration,@EnableAutoConfiguration和@ComponentScan@RestController返回json字符串的数据,直接可以编写RESTFul的接口;@RestController @SpringBootApplication public class App { @RequestMapping("/") public String hello(){ return "Hello world!"; } public static void main(String[] args) { SpringApplication.run(App.class, args); } }
http://127.0.0.1:8080/ 访问
阅读全文
0 0
- springboot的helloworld
- SpringBoot-HelloWorld
- SpringBoot HelloWorld
- SpringBoot HelloWorld
- Springboot-HelloWorld
- springboot---helloworld
- Springboot 之 Helloworld
- SpringBoot入门之HelloWorld
- 2.Springboot 之 Helloworld
- SpringBoot入门之HelloWorld
- springboot之helloworld
- SpringBoot搭建HelloWorld工程
- SpringBoot之Helloworld
- SpringBoot学习笔记--HelloWorld
- Springboot学习一 helloworld
- SpringBoot(1)--------helloworld
- Springboot 环境搭建-helloworld
- SpringBoot学习——SpringBoot入门HelloWorld
- OpenCV3.3出炉,DNN为最大亮点
- 1-9配置和保护openssh服务
- PHP安装pdo扩展
- 字符编码的历史演变
- 51nod1154(回文串划分)
- springboot的helloworld
- PAT 乙级 1022.D进制的A+B(20)
- java连接mysql数据库
- JDK官方下载最新版
- HDU 4004 题解
- 浅谈knn(k近邻)算法
- springboot单元测试找不到@SpringApplicationConfiguration注解
- 红黑树之理解
- idea phpstrom