一、基础Spring-boot快速启动
1.1 快速启动 pom.xml加入如下依赖
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.5.RELEASE</version>
</parent> <properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>spring-docker</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
Spring-boot启动类
@SpringBootApplication
public class DockerApplication { public static void main(String[] args) {
SpringApplication.run(DockerApplication.class, args);
}
}
测试API
@RestController
public class DockerStarterApi { @GetMapping("/api/docker/hello")
public String hello() {
return "hello docker";
}
}
配置启动配置文件
application.yml
server:
port: 9090 # 为了展示效果, 这里改了默认端口8080检查Spring启动
. ____ _ __ _ _
/ / ___'_ __ _ _(_)_ __ __ _
( ( )___ | '_ | '_| | '_ / _` |
/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |___, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.2.RELEASE)...
2018-12-17 17:26:13.385 INFO 48740 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2018-12-17 17:26:13.448 INFO 48740 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 9090 (http) with context path ''
2018-12-17 17:26:13.453 INFO 48740 --- [ main] pers.study.docker.DockerApplication : Started DockerApplication in 1.982 seconds (JVM running for 2.602)










