Followed the Java rest service tutorial at https://spring.io/guides/gs/rest-service/

Machine: Windows10 => quick notes

Downloaded the trial version of IntelliJ IDEA at https://www.jetbrains.com/idea/

Cloned the demo project in a random folder with

git clone https://github.com/spring-guides/gs-rest-service.git

Import the project in the IDE

please select SDK: 1.8

Opted for  Maven

http://maven.apache.org/

Initialisation with gs-rest-service\complete\pom.xml

From an earlier project Jenkins is hugging the default port 8080 but how to switch ports?

Generate a file src/main/resources/application.properties en add the line

server.port=9090

Then hit Run >> Application (Shift F10) in the IDE

this will fire up the C:\Program Files\Java\jdk1.8.0_144\bin\java.exe executable with tons of arguments

From the command line check that Tomcat is running:

INFO 3064 o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 9090 (http)
INFO 3064 — [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
INFO 3064 — [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.34

Then in the browser request

http://localhost:9090/greeting

and the REST service greets back.

For another very recent tutorial on this topic:

https://technology.amis.nl/2019/02/26/building-a-restful-web-service-with-spring-boot-using-an-h2-in-memory-database-and-also-an-external-mysql-database/

Advertisements