Skip to content

Commit 09be857

Browse files
committed
init commit
0 parents  commit 09be857

File tree

8 files changed

+195
-0
lines changed

8 files changed

+195
-0
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.gradle
2+
.idea
3+
build
4+
SpringBootKotlin.iml
5+
SpringBootKotlin.ipr
6+
SpringBootKotlin.iws

Procfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: java -jar build/libs/springBootKotlinApplication-0.1.0.jar --port $PORT

build.gradle

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
buildscript {
2+
ext.kotlin_version = '1.1.0'
3+
ext.junit_version = '4.12'
4+
ext.freemarker_version = '2.3.23'
5+
ext.spting_boot_version = '1.5.2.RELEASE'
6+
7+
repositories {
8+
mavenCentral()
9+
}
10+
11+
dependencies {
12+
classpath('se.transmode.gradle:gradle-docker:1.2')
13+
classpath("org.freemarker:freemarker:$freemarker_version")
14+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
15+
classpath("org.springframework.boot:spring-boot-gradle-plugin:$spting_boot_version")
16+
}
17+
}
18+
19+
group 'com.liuwill.demo'
20+
version '1.0-SNAPSHOT'
21+
22+
apply plugin: 'java'
23+
apply plugin: 'idea'
24+
apply plugin: 'findbugs'
25+
apply plugin: 'application'
26+
apply plugin: "kotlin"
27+
apply plugin: 'docker'
28+
apply plugin: 'org.springframework.boot'
29+
30+
sourceCompatibility = 1.8
31+
targetCompatibility = 1.8
32+
33+
repositories {
34+
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
35+
maven{ url 'http://maven.oschina.net/content/groups/public/'}
36+
mavenCentral()
37+
jcenter()
38+
}
39+
40+
dependencies {
41+
// tag::jetty[]
42+
compile("org.springframework.boot:spring-boot-starter-web") {
43+
exclude module: "spring-boot-starter-tomcat"
44+
}
45+
compile("org.springframework.boot:spring-boot-starter-jetty")
46+
// end::jetty[]
47+
// tag::actuator[]
48+
compile("org.springframework.boot:spring-boot-starter-actuator")
49+
50+
compile "org.freemarker:freemarker:$freemarker_version"
51+
52+
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
53+
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
54+
55+
testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
56+
testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
57+
testCompile group: 'junit', name: 'junit', version: '4.12'
58+
testCompile("org.springframework.boot:spring-boot-starter-test")
59+
}
60+
61+
jar {
62+
baseName = 'springBootKotlinApplication'
63+
version = '0.1.0'
64+
}
65+
bootRepackage {
66+
mainClass = 'com.liuwill.demo.kotlinBoot.SpringBootKotlinApplicationKt'
67+
}
68+
mainClassName = 'com.liuwill.demo.kotlinBoot.SpringBootKotlinApplicationKt'
69+
70+
task buildDocker(type: Docker, dependsOn: build) {
71+
push = true
72+
applicationName = jar.baseName
73+
dockerfile = file('src/main/docker/Dockerfile')
74+
doFirst {
75+
copy {
76+
from jar
77+
into stageDir
78+
}
79+
}
80+
}
81+
82+
sourceSets{
83+
main{
84+
java {srcDir "src/main/java"}
85+
kotlin {srcDir "src/main/kotlin"}
86+
resources {srcDir "src/main/resources"}
87+
}
88+
test{
89+
java {srcDir "src/test/java"}
90+
kotlin {srcDir "src/test/kotlin"}
91+
resources {srcDir "src/test/resources"}
92+
}
93+
}
94+
95+
compileKotlin {
96+
kotlinOptions.suppressWarnings = true
97+
}
98+
99+
tasks.withType(JavaCompile) {
100+
options.encoding = 'UTF-8'
101+
}
102+
103+
task createJavaProject << {
104+
sourceSets*.java.srcDirs*.each { it.mkdirs() }
105+
sourceSets*.kotlin.srcDirs*.each { it.mkdirs() }
106+
sourceSets*.resources.srcDirs*.each { it.mkdirs()}
107+
}
108+
109+
/*
110+
test {
111+
//exclude 'com.liuwill.text.tools.*'
112+
filter {
113+
//include all integration tests
114+
includeTestsMatching "*Test"
115+
116+
//include all tests from package
117+
includeTestsMatching "com.liuwill.kata.test.*"
118+
}
119+
}*/
120+
121+
// [ FindBugs Start**/
122+
findbugs{
123+
ignoreFailures=true
124+
findbugsTest.enabled=false
125+
}
126+
127+
tasks.withType(FindBugs) {
128+
reports {
129+
xml.enabled = false
130+
html.enabled = true
131+
}
132+
}
133+
// ] FindBugs End**/

settings.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
rootProject.name = 'SpringBootKotlin'
2+

src/main/docker/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM frolvlad/alpine-oraclejdk8:slim
2+
VOLUME /tmp
3+
ADD springBootKotlinApplication-0.1.0.jar app.jar
4+
RUN sh -c 'touch /app.jar'
5+
ENV JAVA_OPTS=""
6+
ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar" ]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.liuwill.demo.kotlinBoot
2+
3+
import org.springframework.boot.SpringApplication
4+
import org.springframework.boot.autoconfigure.SpringBootApplication
5+
6+
/**
7+
* Created by liuwill on 2017/3/15.
8+
*/
9+
@SpringBootApplication
10+
open class SpringBootKotlinApplication
11+
12+
fun main(args: Array<String>){
13+
SpringApplication.run(SpringBootKotlinApplication::class.java,*args)
14+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.liuwill.demo.kotlinBoot.controllers
2+
3+
import org.springframework.beans.factory.annotation.Autowired
4+
import org.springframework.web.bind.annotation.RequestMapping
5+
import org.springframework.web.bind.annotation.RequestMethod
6+
import org.springframework.web.bind.annotation.RestController
7+
8+
/**
9+
* Created by liuwill on 2017/3/15.
10+
*/
11+
@RestController
12+
@RequestMapping(value = "api/data")
13+
class DataController {
14+
15+
@RequestMapping(value = "",method = arrayOf(RequestMethod.GET,RequestMethod.PUT))
16+
fun index():Map<String,Any>{
17+
val resultMap = HashMap<String,Any>()
18+
19+
resultMap["status"] = true
20+
resultMap["code"] = "100010"
21+
resultMap["msg"] = "success"
22+
resultMap["data"] = "data"
23+
return resultMap
24+
}
25+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
server.port=8888
2+
local.server.port = 8888
3+
4+
spring.resources.chain.strategy.content.enabled=true
5+
spring.resources.chain.strategy.content.paths=/static/**
6+
spring.mvc.static-path-pattern=/static/** # Path pattern used for static resources.
7+
8+
spring.freemarker.cache=false

0 commit comments

Comments
 (0)