Spring Boot来简化SPring应用开发,约定大于配置,去繁从简,just run就能建立一个独立的,产品级别应用java
背景:git
J2EE笨重的开发、繁多的配置、低下的开发效率、发杂的部署流程、第三方技术集成难度发github
2014,martin fowler 微服务:架构风格
一个应用应该是一组小型服务;能够经过HTTP的方式进行互通;
每个功能元素最终都是一个可独立替换和独立升级软件的单元web
给maven的settings.xml配置文件的profiles标签添加spring
<profiles> <profile> <id>jdk-1.8</id> <activation> <activeByDefault>true</activeByDefault> <jdk>1.8</jdk> </activation> <properties> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion> </properties> </profile> </profiles>
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.9.RELEASE</version> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies>
/** * @SpringBootApplication 来标注一个主程序类,说明这是一个Spring Boot应用 */ @SpringBootApplication public class HelloWorLdMainApplication { public static void main(String[] args) { //Spring应用启动起来 SpringApplication.run(HelloWorLdMainApplication.class,args); }
@Controller public class HelloController { @ResponseBody @RequestMapping("/hello") public String hello(){ return "Hello World"; } }
<!--这个插件,能够将应用打包成一个可执行的jar包;--> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build>
点击右边的Maven Project-package将这个应用打成jar架构
经过cmd直接使用java-jar的命令进行执行; app
完成效果框架