####TODO:
-
- Test docker in windows
-
- How to do Http to Https forward in Embedded Jetty?
This is a skeleton project using spring.
The main idea behind this is to have a working java spring web and/or rest application up and running as quick as possible, seeing as creating a new java project is usually a very time consuming process.
Everything should be completely automatic with the exception of the database creation. Default database name is "example". It can be changed in application.properties.
spring.datasource.url = jdbc:mysql://localhost:3306/example
spring.datasource.username = root
spring.datasource.password =
So far, the project includes:
- Java 1.8.
- Lots and lots of Spring:
- Spring Boot (doing most of the heavy work behind curtains).
- Spring MVC.
- Spring REST.
- Spring Data JPA with mysql (can be easily changed to any other, including mongoDB).
- Spring Security (with basic auth AND login/logout pages).
- Spring SSL support, with Maven copying your keystore.jks automatically. (http://docs.spring.io/spring-security-saml/docs/current/reference/html/security.html)
- Spring Mail (with thymeleaf templates, just like webpages, and attachment support).
- Spring MVC Internationalization.
- Spring Profiles development and production, with dev as default. To run in production, simply pass --env="production" to java -jar, or change the spring.profiles.active to ${env:production} in external application.properties. Running in production requires root access as only root can deploy to ports 80 and 443.
- Spring + Compile Time Weave with AspectJ for @Configurable support. (http://docs.spring.io/spring/docs/current/spring-framework-reference/html/aop.html#aop-using-aspectj).
- Spring global rest exceptions (for user-friendly exception handling in rest requests).
- Web views using Thymeleaf templates and pure html (similar to how ruby does it and much cleaner than JSF).
- WebJars support. Let Maven manage your third party JS dependencies. (http://www.webjars.org/).
- Automatic admin creation during boostrap using @PostConstruct and with data from application.properties. (You may create a BootstrapController to add more boostrap actions using @PostConstruct)
- Lombok support. And it works with AspectJ! (http://projectlombok.org/).
- Caching with ehcache supported (via xml, as it's a lot cleaner than java code).
- Logging with log4j (log to file in production and different properties for development and production environments).
- Spring Test with Rest Assured support (http://www.jayway.com/2014/07/04/integration-testing-a-spring-boot-application/)
- Docker support with automatic image creation via POM.xml (not tested in windows) (https://spring.io/guides/gs/spring-boot-docker/)
- External application.properties file to override any properties you want during runtime.
- Maven local repository example in pom.xml. (Example: https://devcenter.heroku.com/articles/local-maven-dependencies).
- Works out of the box both as a JAR as well as a deployable or executable WAR.
- Running on embedded Tomcat. Can be easily switched to Jetty (http://docs.spring.io/spring-boot/docs/current/reference/html/howto-embedded-servlet-containers.html#howto-use-jetty-instead-of-tomcat).
- More examples and explanations are in code comments.
####RUN AS DEPLOYABLE WAR: http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#build-tool-plugins-maven-packaging
-
- Change package to war in pom.xml:
<packaging>war</packaging>
-
- Add this dependency in pom.xml, below the Spring Boot Starter Core dependencies :
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
-
- Add this plugin in pom.xml, below the spring-boot-maven-plugin :
<!-- Webapps Resources -->
<!-- Since we already have the minified css and js and don't need the original files in the packaging -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<packagingExcludes>resources/</packagingExcludes>
</configuration>
</plugin>
-
- Delete this line in pom.xml:
<!-- Webapps Resources -->
<!-- Since we already have the minified css and js and don't need the original files in the packaging -->
<resource>
<directory>${basedir}/src/main/webapp</directory>
<filtering>false</filtering>
<excludes>
<exclude>resources/**</exclude>
</excludes>
</resource>
####REMOVE WEB CONTENT: If you don't need a WEB Application:
-
Delete the folder webapp/webpages AND webapp/templates. You will then use thymeleaf only for email templates.
-
If you want absolutely NOTHING to do with HTML and WEB pages:
- Delete the webapp folder entirely
- Remove ThymeleafConfig.java
- Remove "Security configuration for web content" in SecurityConfig.java and change the security configurations to your liking
- Delete Controllers' WEB folder
- Remove LocalizationConfig.java and the resources/i18n folder
- Remove MailerService.java
- Remove thymeleaf configurations from application.properties
- Remove all Thymeleaf AND WebJar dependencies from pom.xml
- Remove this resource from pom.xml:
<!-- Webapps Resources-->
<!-- Since we already have the minified css and js and don't need the original files in the packaging -->
<resource>
<directory>${basedir}/src/main/webapp</directory>
<filtering>false</filtering>
<excludes>
<exclude>resources/**</exclude>
</excludes>
</resource>
####WARNING: KEYSTORE IS INVALID. PLEASE CREATE ONE TO SUBSTITUTE.