Emac
2016/7
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
$java -jar demo-0.0.1-SNAPSHOT.jar
$mvn spring-boot:run
OR
Manifest-Version: 1.0 Implementation-Title: demo Implementation-Version: 0.0.1-SNAPSHOT Archiver-Version: Plexus Archiver Built-By: emac Start-Class: com.example.DemoApplication Implementation-Vendor-Id: com.example Spring-Boot-Version: 1.3.6.RELEASE Created-By: Apache Maven 3.3.3 Build-Jdk: 1.8.0_60 Implementation-Vendor: Pivotal Software, Inc. Main-Class: org.springframework.boot.loader.JarLauncher
@Autowired
private Environment env;
注解扫描
条件加载
属性注入
(Dependency-Driven-Configuration)
# DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties)
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8&rewriteBatchedStatements=true # JDBC url of the database.
spring.datasource.username=root
spring.datasource.password= # Login password of the database.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
1. 添加依赖
2. 配置属性