Skip to content

Commit 806fdde

Browse files
committed
[FIX] #26 SpringBootDocker
1 parent f9fe79e commit 806fdde

File tree

6 files changed

+64
-31
lines changed

6 files changed

+64
-31
lines changed

SpringBootDocker/build.gradle

+32-25
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,41 @@
1-
buildscript {
2-
ext {
3-
springBootVersion = '2.1.3.RELEASE'
4-
}
5-
repositories {
6-
mavenCentral()
7-
}
8-
dependencies {
9-
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
10-
}
11-
}
12-
131
plugins {
14-
id 'com.google.cloud.tools.jib' version '0.9.11'
2+
id 'org.springframework.boot' version '2.1.3.RELEASE'
3+
id 'org.jetbrains.kotlin.jvm' version '1.2.71'
4+
id 'org.jetbrains.kotlin.plugin.spring' version '1.2.71'
5+
id 'com.google.cloud.tools.jib' version '1.0.2'
156
}
167

17-
apply plugin: 'java'
18-
apply plugin: 'eclipse'
19-
apply plugin: 'org.springframework.boot'
208
apply plugin: 'io.spring.dependency-management'
219

22-
sourceCompatibility = 1.8
23-
targetCompatibility = 1.8
10+
group = 'com.example'
11+
version = '0.0.1-SNAPSHOT'
12+
sourceCompatibility = '1.8'
2413

2514
repositories {
2615
mavenCentral()
2716
}
2817

2918
dependencies {
30-
compile('org.springframework.boot:spring-boot-starter-web')
31-
testCompile('org.springframework.boot:spring-boot-starter-test')
19+
implementation 'org.springframework.boot:spring-boot-starter-web'
20+
implementation 'com.fasterxml.jackson.module:jackson-module-kotlin'
21+
implementation 'org.jetbrains.kotlin:kotlin-reflect'
22+
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
23+
24+
testImplementation 'org.springframework.boot:spring-boot-starter-test'
25+
}
26+
27+
compileKotlin {
28+
kotlinOptions {
29+
freeCompilerArgs = ['-Xjsr305=strict']
30+
jvmTarget = '1.8'
31+
}
32+
}
33+
34+
compileTestKotlin {
35+
kotlinOptions {
36+
freeCompilerArgs = ['-Xjsr305=strict']
37+
jvmTarget = '1.8'
38+
}
3239
}
3340

3441
jib {
@@ -38,14 +45,14 @@ jib {
3845
to {
3946
image = 'registry.hub.docker.com/heowc1992/my-app'
4047
auth {
41-
username = dockerUsername
42-
password = dockerPassword
48+
username = dockerUsername
49+
password = dockerPassword
4350
}
4451
}
4552
container {
4653
jvmFlags = ['-Djava.security.egd=file:/dev/./urandom', '-Duser.timezone=GMT+09']
47-
mainClass = 'com.heowc.Application'
48-
// args = ['some args']
54+
mainClass = 'com.example.java.SpringBootDockerApplication'
55+
// mainClass = 'com.example.kotlin.SpringBootDockerApplicationKt'
4956
ports = ['8080']
5057
}
51-
}
58+
}

SpringBootDocker/src/main/java/com/heowc/SimpleController.java renamed to SpringBootDocker/src/main/java/com/example/java/SimpleController.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.heowc;
1+
package com.example.java;
22

33
import org.springframework.web.bind.annotation.GetMapping;
44
import org.springframework.web.bind.annotation.RequestMapping;
@@ -10,6 +10,6 @@ public class SimpleController {
1010

1111
@GetMapping
1212
public String message() {
13-
return "Hello Jib!!";
13+
return "Hello Jib With Java!!";
1414
}
1515
}
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
package com.heowc;
1+
package com.example.java;
22

33
import org.springframework.boot.SpringApplication;
44
import org.springframework.boot.autoconfigure.SpringBootApplication;
55

66
@SpringBootApplication
7-
public class Application {
7+
public class SpringBootDockerApplication {
88

99
public static void main(String[] args) {
10-
SpringApplication.run(Application.class, args);
10+
SpringApplication.run(SpringBootDockerApplication.class, args);
1111
}
1212
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.example.kotlin
2+
3+
import org.springframework.web.bind.annotation.GetMapping
4+
import org.springframework.web.bind.annotation.RequestMapping
5+
import org.springframework.web.bind.annotation.RestController
6+
7+
@RestController
8+
@RequestMapping("/")
9+
class SimpleController {
10+
11+
@GetMapping
12+
fun message(): String {
13+
return "Hello Jib With Kotlin!!"
14+
}
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.example.kotlin
2+
3+
import org.springframework.boot.autoconfigure.SpringBootApplication
4+
import org.springframework.boot.runApplication
5+
6+
@SpringBootApplication
7+
class SpringBootDockerApplication
8+
9+
fun main(args: Array<String>) {
10+
runApplication<SpringBootDockerApplication>(*args)
11+
}

SpringBootDocker/src/test/java/com/heowc/ApplicationTests.java renamed to SpringBootDocker/src/test/java/com/heowc/SpringBootDockerApplicationTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
@RunWith(SpringRunner.class)
99
@SpringBootTest
10-
public class ApplicationTests {
10+
public class SpringBootDockerApplicationTests {
1111

1212
@Test
1313
public void contextLoad() {

0 commit comments

Comments
 (0)