SpringBoot:J2EE一站式解决方案。解决配置繁琐,开发效率低。
SpringCloud:分布式解决方案。
优点:
约束环境:
--jdk1.7以上
--maven3.X
--springBoot 最好使用稳定版
maven编译版本:使用1.8版本jdk
修改 在maven的setting中 。
修改为IDEA自己的配置文件:
导入jar:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.6.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
2.编写main
package com.chen;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* @Autre beyond
* @Data 2019/9/20
*/
@SpringBootApplication()
public class hellword {
public static void main(String[] args) {
//spring 应用启动
SpringApplication.run(hellword.class,args);
}
}
编写Controller:
package com.chen;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication()
public class hellword {
public static void main(String[] args) {
//spring 应用启动
SpringApplication.run(hellword.class,args);
}
}
打包成可以执行的jar包:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
使用方法:
Pom文件讲解:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.6.RELEASE</version>
</parent>
parent依赖:
v:最后时
最后是:
然后是:
spring-boot-starts-web:
导入web模块。比如SpringMVC
总的来说Spring—boot把每个功能模块做成一个个starter,使用的时候直接导入就行。
版本根据parent控制。
原文:https://www.cnblogs.com/huzi626/p/13912858.html