Skip to content

Sample application using Spring 5 Annotation Configuration, RestTemplate, Gradle, and Tomcat.

Notifications You must be signed in to change notification settings

big-owl/MySpringApplication

Repository files navigation

MySpringApplication

Description

This project is my attempt to develop a simple web application with a "backend service" using Spring 5, JUnit 5, Java 9, RestTemplate, Gradle, SLF4J and Tomcat.

Getting Started

  1. Use 'tomcatRun' or 'tomcatRunWar' gradle task to start a tomcat instance, and deploy to it.
  2. Either run http://localhost:8080/application from the browser, or run 'ClientTest' from your IDE.

Next Steps

  • Improve unit testing using MockMvc.
  • Replace hard-coded values with dependency injection.
  • Modularize services.
  • Upgrade to Spring Boot.
  • Add an in-memory database, like H2.

Considerations

  • Standard Spring MVC project structure seems to be that the view directory is under the WEB-INF directory. This enforces good habits (like MVC), but it prevents you from accessing the page directly.

Known Issues

  • I wanted my default home page to be an html file (index.html), but I kept getting 404 errors. Either no mapping could be found, or I was unable to get the ViewResolver to ignore the html files.
  • The application must be running (tomcatRun) before the "unit tests" can be started. Otherwise, you will get a "connection refused" message. This also throws off the test coverage metrics.

References

Gradle Tomcat Plugin
Spring4 Restful Example
Spring4 Annotation Configuration
Spring Validation Example
Slf4J Example
JUnit 5 with Gradle

About

Sample application using Spring 5 Annotation Configuration, RestTemplate, Gradle, and Tomcat.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages