An example application using AnguarJS/Bootstrap as frontend and Spring MVC as REST API producer.
More details about the codes, please read the online GitBook: Building REST APIs with Spring MVC.
- Spring Boot
- Spring MVC
- Spring Data JPA
- Hibernate 5.2
- Spring Security
- Swagger/Swagger2Markup/Spring Rest Docs
- Spring Test/JUnit/Mockito/JBehave/RestAssured
This version improved the original version, including:
- Introduction of Gulp build system to processing the static resources
- The frontend UI can be run standalone via NodeJS eco-system
- An option provided and allow you to package the static resources as part of final jar and run the application via
- JDK 8
Oracle Java 8 is required, go to Oracle Java website to download it and install into your system.
Optionally, you can set JAVA_HOME environment variable and add <JDK installation dir>/bin in your PATH environment variable.
- Apache Maven
Download the latest Apache Maven from http://maven.apache.org, and uncompress it into your local system.
Optionally, you can set M2_HOME environment varible, and also do not forget to append <Maven Installation dir>/bin your PATH environment variable.
NodeJS is required to build the frontend static resources.
Download NodeJS and install it into your local system.
After it is installed, open terminal, and using
node -v command to confirm.
node -v >v4.2.2
bower is also requried to install the runtime dependencies, and
gulp is chosen as our build tools for the statics resources.
npm install -g bower npm install -g gulp
Get the source codes
Get a copy of the source codes into your local system.
git clone https://github.com/hantsy/angularjs-springmvc-sample-boot
Run the project
Run frontend UI and backend respectively
- Run the backend API server via Spring Boot.
The backend APIs will run on port 9000.
- Run the frontend UI standalone.
npm install bower install gulp serve
By default, gulp serves the frontend UI static resources on port 3000.
- Go to http://localhost:3000 to test it.
Run the project via Spring Boot maven plugin
- Run the following command to resovle the dependencies of the frontend static resources.
npm install bower install
- Run the backend API server with
spring-bootcommand. The parameter
-Dstatic-uiwill copy the static resources and package into the jar archive.
mvn spring-boot:run -Dstatic-ui
- Go to http://localhost:9000 to test it.
If you want to explore the REST API docs online, there is a Swagger UI configured for visualizing the REST APIs, just go to http://localhost:9000/swagger-ui.html.