spring boot first
look into hello2.groovy then terminal spring run hello2.groovy then browser 127.0.0.1:8080
-
need to open project kotlin-learning
- open KotinLearningApplication.kt
- mouse right click on fun main and run it
- browser open 127.0.0.1:8080/rest/users/all, empty initially
- then 127.0.0.1:8080/rest/users/insert/peter, show 1 user json
- then 127.0.0.1:8080/rest/users/insert/sam, show 2 users json
-
refer to video tutorial Spring Boot (Spring MVC and JPA) App using Kotlin in Java 8 runtime | Tech Primers
-
learn how to use project generator from [spring io start] (https://start.spring.io/)
- execute
mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
- then my-app folder generated, move into the folder, then build it
mvn package
- build error encountered like
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project my-app: Compilation failure: Compilation failure:
[ERROR] Source option 5 is no longer supported. Use 7 or later.
[ERROR] Target option 5 is no longer supported. Use 7 or later.
- update pom.xml, refer to Error “Source option 5 is no longer supported. Use 6 or later” on Maven compile
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
- build ok, run
java -cp target/my-app-1.0-SNAPSHOT.jar com.mycompany.app.App
- first maven example
initial successful test for spring boot, 1st and 2nd examples