Skip to content

Commit

Permalink
embeded tomcat
Browse files Browse the repository at this point in the history
  • Loading branch information
nano.son committed Jul 14, 2019
1 parent 2a4cbd0 commit e8d398a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
8 changes: 8 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ repositories {

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"

// https://mvnrepository.com/artifact/org.apache.tomcat.embed/tomcat-embed-core
compile group: 'org.apache.tomcat.embed', name: 'tomcat-embed-core', version: '9.0.22'


// https://mvnrepository.com/artifact/org.springframework/spring-webmvc
compile group: 'org.springframework', name: 'spring-webmvc', version: '5.1.8.RELEASE'

}

compileKotlin {
Expand Down
11 changes: 10 additions & 1 deletion src/main/kotlin/Main.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
import org.apache.catalina.startup.Tomcat
import java.io.File

class Main {
companion object {
@JvmStatic
fun main(args: Array<String>) {
println("hello world")
val tomcat = Tomcat().apply {
setPort(8080)
addWebapp("/", File("src/main/myapp").absolutePath)
connector
}
tomcat.start()
tomcat.server.await()
}
}
}
6 changes: 6 additions & 0 deletions src/main/myapp/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<html>
<head></head>
<body>
<h1>hello world</h1>
</body>
</html>

0 comments on commit e8d398a

Please sign in to comment.