SpringBoot
2016-06-22 15:54
323 查看
Spring Boot提供了一个强大的一键式Spring的集成开发环境,能够单独进行一个Spring应用的开发,其中:
(1)集中式配置(application.properties)+注解,大大简化了开发流程
(2)内嵌的Tomcat和Jetty容器,可直接打成jar包启动,无需提供Java war包以及繁琐的Web配置
(3)提供了Spring各个插件的基于Maven的pom模板配置,开箱即用,便利无比。
(4)可以在任何你想自动化配置的地方,实现可能
(5)提供更多的企业级开发特性,如何系统监控,健康诊断,权限控制
(6) 无冗余代码生成和XML强制配置
(7)提供支持强大的Restfult风格的编码,非常简洁
开发SpringBoot项目:
1. 创建Maven项目
2. 添加SpringBoot jar包依赖
3. 编写接口
4. 发布程序
5. 访问接口
pom.xml
测试
(1)集中式配置(application.properties)+注解,大大简化了开发流程
(2)内嵌的Tomcat和Jetty容器,可直接打成jar包启动,无需提供Java war包以及繁琐的Web配置
(3)提供了Spring各个插件的基于Maven的pom模板配置,开箱即用,便利无比。
(4)可以在任何你想自动化配置的地方,实现可能
(5)提供更多的企业级开发特性,如何系统监控,健康诊断,权限控制
(6) 无冗余代码生成和XML强制配置
(7)提供支持强大的Restfult风格的编码,非常简洁
开发SpringBoot项目:
1. 创建Maven项目
2. 添加SpringBoot jar包依赖
3. 编写接口
4. 发布程序
5. 访问接口
pom.xml
<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> <!-- 项目名称,由于有的项目并不是一个jar包构成的,而是由很多的jar包组成的。因此这个groupId就是整个项目的名称。 --> <groupId>com.test</groupId> <!-- 包的名称 --> <artifactId>maven</artifactId> <version>0.0.1-SNAPSHOT</version> <!-- 包的类型,一般都是jar,也可以是war之类的。如果不填,默认就是jar --> <packaging>jar</packaging> <name>maven</name> <!-- maven的地址 --> <url>http://maven.apache.org</url> <!-- 项目统一字符集编码 --> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.2.3.RELEASE</version> </parent> <dependencies> <!--junit jar依赖 --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <!--SpringBoot jar依赖 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <version>1.0.2.RELEASE</version> </dependency> </dependencies> </project>
测试
package com.test.maven; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; @Controller @EnableAutoConfiguration public class TestController { @RequestMapping(value ="/hello", method = RequestMethod.GET) @ResponseBody public String hello(){ return "你好 hello world"; } //发布程序 public static void main(String[] args) { SpringApplication.run(TestController.class, args); } }
相关文章推荐
- JDK源码分析之String篇
- java的位运算符
- java导出word实现方式二,poi
- 【转载】Java 对象之生
- Java IO
- JAVA常用代码。干货来啦!
- springmvc(基础三) Springmvc 数据绑定
- 深入理解Java内存模型(一)——基础
- 《java并发编程实战》第11章-性能与可伸缩性
- Spring 4.x官方参考文档中文版——第21章 Web MVC框架(14)
- java导出word实现方式一,在jsp中实现
- spring管理下的声明式事务与存储过程之间的记录
- 对象类型转换
- springmvc和mybaits整合(五)-商品查询controller
- java压缩文件
- Java多线程编程总结(转载)
- java常用代码
- Java字符串拆分问题
- Java字符串拆分问题
- java对象类型转换