Ensure you have the following installed:
- https://jdk.java.net (We have used Java JDK 14) and then extract it to C:\Program Files\Java\jdk-14.0.2
- JAVA_HOME also needs to be set within environment variables (pointing to the Java JDK installation) https://confluence.atlassian.com/conf59/setting-the-java_home-variable-in-windows-792499849.html
- The bin folder needs to be added to the PATH environment variable by adding %JAVA_HOME%\bin to the PATH https://javatutorial.net/set-java-home-windows-10
- Restart after the above
- https://www.eclipse.org/downloads (We have used Eclipse IDE 2020-06 which is free to download, another alternative is NetBeans, but for developers who already have IntelliJ we recommend IntelliJ) -> option to select in the installer is “Eclipse IDE for Enterprise Java Developers”
- MySQL (TODO: Link)
- MySql Workbench (TODO: Link)
We will also be using Lombok, it can be installed in Eclipse as follows:
- Run cmd as an Administrator
- cd C:\Users\Valentina.Cupac.m2\repository\org\projectlombok\lombok\1.18.12
- java -jar lombok-1.18.12.jar
- Project Lombok Installer appears -> it scans the IDE installations.
- After installations are selected, click on “Install / Update”
Current build tool used is Maven (which is the most popular build tool) but there is also Gradle (pending switch to Gradle). Keep this in mind when importing projects.
Project setup (Eclipse)
- Open up MySql Workbench.
- Create a schema called “lite” (clicking on the Icon “Create a new schema in the connected server” and then in name write “lite” and then OK).
Since we’re using Maven, it means to open up the project in Eclipse:
- Open up Eclipse
- Click on File > Import
- Select Maven > Existing Maven Projects
- Click on Next.
- For Root Directory, click on Browse.
- Click the folder atomiv > atomiv-java > template-lite, then click on template.lite.web.restapi (but don’t open it) and click on “Select Folder” button
- Click on “Finish”
- The newly imported project template.lite.web.restapi appears in the Project Explorer on the left sidebar
Configuring template (Eclipse)
- Open up Eclipse
- Expand src/main/resources
- Open up application.properties
- Check the fields for spring.datasource.username and spring.database.password
Running template (Eclipse)
- Open up src/main/java and expland org.atomiv.template.lite.web.restapi
- Right-hand click on Application.java and click on Run As > Java Application
- When it runs you should see Tomcat initialized with port(s): 8080 (http)
- Also, the first time that it’s run, Hibernate will generate tables inside the “lite” schema
Manual testing (Swagger)
- Open up Swagger http://localhost:8080/swagger-ui.html
- Click on customer-controller, then POST api/customers, then “Try it out” then “Execute”
- Verify that the response is 200.
- Run GET api/customers, click on “Try it out” then “Execute”
- verify that the response is 200 and that you can see the newly added customer
Running the template (command line)
The template is here https://github.com/atomiv/atomiv-java.
cd template.web.restapi ./mvnw spring-boot:run
There will be a success message: Tomcat started on port(s): 8080 (http)
Then go into the browser, type in http://localhost:8080/ and you will see the message “Hello to this app!”