$ cd /Users/zhangkai/exception-coder/thinking-in-spring-boot/
# 使用 maven archetype 插件创建 maven 工程
$ mvn archetype:generate -DgroupId=thinking-in-spring-boot -DartifactId=first-spring-boot-application -Dversion=1.0.0-SNAPSHOT -DinteractiveMode=false -Dpackage=thinking.in.spring.boot
$ cd first-spring-boot-application
$ tree
.
├── pom.xml
└── src
├── main
│ └── java
│ └── thinking
│ └── in
│ └── spring
│ └── boot
│ └── App.java
└── test
└── java
└── thinking
└── in
└── spring
└── boot
└── AppTest.java
# 对 pom.xml 文件进行编辑
$ vim pom.xml
$ mvn dependency:tree -Dincludes=org.springframework*
# 编辑引导类
$ vim src/main/java/thinking/in/spring/boot/App.java
$ mvn spring-boot:run
-
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/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <!-- 增加 Spring Boot Parent POM --> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.1.5.RELEASE</version> </parent> <groupId>thinking-in-spring-boot</groupId> <artifactId>first-spring-boot-application</artifactId> <packaging>jar</packaging> <version>1.0.0-SNAPSHOT</version> <name>first-spring-boot-application</name> <url>http://maven.apache.org</url> <dependencies> <!-- 增加 Spring Boot Web 依赖--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <version>2.1.5.RELEASE</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> </project>
-
-
App.java
package thinking.in.spring.boot; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; /** * Hello world! * */ @RestController @SpringBootApplication public class App { @RequestMapping("/") public String index(){ return "Weclome,My Buddy!" ; } public static void main( String[] args ) { System.out.println( "Hello World!" ); } }
// TODO
分水岭:Spring Framework 1.2.0。
支持注解:@ManagedResource 、 @Transactional 等
配置方式:XML
分水岭:Spring Framework 2.5
支持注解:@Repository、@Aspect、@Autowired、@Qualifier、@Component、@Service、@Controller、@RequestMapping、@ModelAttribute
配置方式:注解+XML
分水岭:Spring Framework 3.1
支持注解:@ImportResource、@Import、@Bean、@DependsOn、@Primary、@ComponentScan、@RequestHeader、@CookieValue、@RequestPart、@PathVariable、@ResponseBody、@ResponseStatus、@PropertySource、@Async、@Scheduled
支持注解:@Conditional(@Profile的重新声明)、@ConditionalOn*(@Conditional "派生"注解)、@PropertySource(被@Repeatable提升为可重复标注的注解)、@ComponentScans(@ComponentScan的提升)、@EventListener(作为ApplicationListener接口编程的第二选择)
支持注解:@Indexed(pom.xml依赖 org.springframework:spring-context-indexer)
-
Spring 模式注解
Spring 注解 场景说明 起始版本 @Repository 数据仓储模式注解 2.0 -
装配注解
-
依赖注入注解
-
Bean定义注解
-
Spring条件装配注解
-
配置属性注解
-
生命周期回调注解
-
注解属性注解
-
性能注解