Spring Boot 入门
- Build systems:
Maven
|Gradle
|Ant
|Starter POMs
- Best practices:
Code Structure
|@Configuration
|@EnableAutoConfiguration
|Beans and Dependency Injection
- Running your code:
IDE
|Packaged
|Maven
|Gradle
- Package your app:
Production jars
- Spring Boot CLI:
Using the CLI
Tips:
Spring Boot use Java SDK v1.6 or higher, running in Tomcat 7.0 or higher.
Maven compile sources fromsrc/main/java
folder by defaule.
SpringApplication will bootstrap our application, starting Spring which will in turn start the auto-configured Tomcat web server.
Executable jars (sometimes called “fat jars”) are archives containing your compiled classes along with all of the jar dependencies that your code needs to run.
project.version.SNAPSHOT.jar.original is the original jar file that Maven created before it was repackaged by Sping Boot.
To create an executable jar we need to add the spring-boot-maven-plugin to our pom.xml.
Each release of Spring Boot is associated with a base version of the Spring Framework so we highly recommend you to not specify its version on your own.
Spring Boot dependencies: https://github.com/spring-projects/spring-boot/blob/v1.3.6.RELEASE/spring-boot-dependencies/pom.xml
Spring Boot Starter reference: https://github.com/spring-projects/spring-boot/blob/master/spring-boot-starters/README.adoc
Annotation Definations:
Stereotype Annotation: Provides hints for people reading the code, and for Spring, that the class plays a specific role.
Annotation | Defination |
---|---|
@Controller | Spring will consider this class when handling incoming web requests. | <