-
Install the Spring Boot CLI
-
Create a new repository under your account on GitHub for an example application that we are going to develop throughout the semester. Name the repository eventregistration. See more on the specification of the application functionality later.
-
Clone it somewhere on your disk. We assume you cloned it to ~/git/eventregistration.
-
Navigate to that folder in the terminal:
cd ~/git/eventregistration
. -
Create a project for the backend application using Spring Boot CLI in this repository.
spring init \ --build=gradle \ --java-version=1.8 \ --package=ca.mcgill.ecse321.eventregistration \ --name=EventRegistration \ --dependencies=web,data-jpa,postgresql \ EventRegistration-Backend
NoteBackslashes in this snippet indicate linebreaks in this one liner command typed in the terminal. You can select and copy-paste this snippet as-is. -
Navigate to the EventRegistration-Backend folder
-
For future use, locate the application.properties file in the src/ folder and add the following content:
server.port=${PORT:8080} spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults = false spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
NoteIt may be the case that the PostgreSQLDialect
needs to be changed for certain database instances (e.g., toPostgreSQL9Dialect
). -
Locate the Java file containing the main application class (
EventRegistrationApplication.java
) and add the following contentpackage ca.mcgill.ecse321.eventregistration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.SpringApplication; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RequestMapping; @RestController @SpringBootApplication public class EventRegistrationApplication { public static void main(String[] args) { SpringApplication.run(EventRegistrationApplication.class, args); } @RequestMapping("/") public String greeting(){ return "Hello world!"; } }
-
Verify that it builds with
gradle build -xtest
. -
Commit and push the files of the new Spring project.
git add . git status #verify the files that are staged for commit git commit -m "Initial commit of the backend application" git push