Skip to content

Commit 4fdf113

Browse files
committed
m
1 parent b8c27a4 commit 4fdf113

File tree

9 files changed

+116
-2
lines changed

9 files changed

+116
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ Spring Boot使用的各种示例,以最简单、最实用为标准
1515

1616
- [spring-boot-hello](https://github.com/ityouknow/spring-boot-examples/tree/master/spring-boot-hello):Spring Boot 2.0 Hello World 示例
1717
- [spring-boot-banner](https://github.com/ityouknow/spring-boot-examples/tree/master/spring-boot-banner):Spring Boot 定制 Banner 示例
18+
- [spring-boot-docker](https://github.com/ityouknow/spring-boot-examples/tree/master/spring-boot-banner):使用 Docker 部署 Spring Boot 示例
19+
1820

1921
**参考文章**
2022

README_EN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Spring Boot Examples, Use the simplest and most useful scene demo.
1414

1515
- [spring-boot-hello](https://github.com/ityouknow/spring-boot-examples/tree/master/spring-boot-hello):Spring Boot 2.0 Hello World Demo
1616
- [spring-boot-banner](https://github.com/ityouknow/spring-boot-examples/tree/master/spring-boot-banner):Spring Boot Customized Banner
17-
17+
- [spring-boot-docker](https://github.com/ityouknow/spring-boot-examples/tree/master/spring-boot-banner):Spring Boot with Docker
1818

1919
---
2020

spring-boot-docker/pom.xml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>com.neo</groupId>
7+
<artifactId>spring-boot-docker</artifactId>
8+
<version>1.0</version>
9+
<packaging>jar</packaging>
10+
11+
<name>spring-boot-docker</name>
12+
<description>Demo project for Spring Boot</description>
13+
14+
<parent>
15+
<groupId>org.springframework.boot</groupId>
16+
<artifactId>spring-boot-starter-parent</artifactId>
17+
<version>2.0.0.RELEASE</version>
18+
</parent>
19+
20+
<properties>
21+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
22+
<java.version>1.8</java.version>
23+
<docker.image.prefix>springboot</docker.image.prefix>
24+
</properties>
25+
26+
<dependencies>
27+
<dependency>
28+
<groupId>org.springframework.boot</groupId>
29+
<artifactId>spring-boot-starter-web</artifactId>
30+
</dependency>
31+
<dependency>
32+
<groupId>org.springframework.boot</groupId>
33+
<artifactId>spring-boot-starter-test</artifactId>
34+
<scope>test</scope>
35+
</dependency>
36+
</dependencies>
37+
38+
<build>
39+
<plugins>
40+
<plugin>
41+
<groupId>org.springframework.boot</groupId>
42+
<artifactId>spring-boot-maven-plugin</artifactId>
43+
</plugin>
44+
<!-- Docker maven plugin -->
45+
<plugin>
46+
<groupId>com.spotify</groupId>
47+
<artifactId>docker-maven-plugin</artifactId>
48+
<version>1.0.0</version>
49+
<configuration>
50+
<imageName>${docker.image.prefix}/${project.artifactId}</imageName>
51+
<dockerDirectory>src/main/docker</dockerDirectory>
52+
<resources>
53+
<resource>
54+
<targetPath>/</targetPath>
55+
<directory>${project.build.directory}</directory>
56+
<include>${project.build.finalName}.jar</include>
57+
</resource>
58+
</resources>
59+
</configuration>
60+
</plugin>
61+
<!-- Docker maven plugin -->
62+
</plugins>
63+
</build>
64+
65+
66+
</project>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM openjdk:8-jdk-alpine
2+
VOLUME /tmp
3+
ADD spring-boot-docker-1.0.jar app.jar
4+
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.neo;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
@SpringBootApplication
7+
public class DockerApplication {
8+
9+
public static void main(String[] args) {
10+
SpringApplication.run(DockerApplication.class, args);
11+
}
12+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.neo.controller;
2+
3+
import org.springframework.web.bind.annotation.RequestMapping;
4+
import org.springframework.web.bind.annotation.RestController;
5+
6+
@RestController
7+
public class DockerController {
8+
9+
@RequestMapping("/")
10+
public String index() {
11+
return "Hello Docker!";
12+
}
13+
}

spring-boot-docker/src/main/resources/application.properties

Whitespace-only changes.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.neo;
2+
3+
import org.junit.Test;
4+
import org.junit.runner.RunWith;
5+
import org.springframework.boot.test.context.SpringBootTest;
6+
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
7+
import org.springframework.test.context.junit4.SpringRunner;
8+
9+
@RunWith(SpringRunner.class)
10+
@SpringBootTest
11+
public class DockerApplicationTests {
12+
13+
@Test
14+
public void contextLoads() {
15+
System.out.println("hello docker");
16+
}
17+
18+
}

spring-boot-hello/pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
<properties>
2121
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2222
<java.version>1.8</java.version>
23-
<docker.image.prefix>springboot</docker.image.prefix>
2423
</properties>
2524

2625
<dependencies>

0 commit comments

Comments
 (0)