A boilerplate Java project focused on deliver basic DevOps flows such Continuous Integration, Continuous Delivery, containerizing with Docker and Cloud Computing over AWS Elastic Beanstalk.
First, be sure that you the mandatory system properties (see section System Properties below) are set within the runtime environment.
Clean and build:
mvn clean install
Skip integration tests:
mvn package -DskipITs
Skip all tests:
mvn package -DskipTests
- JDK 1.8
- Maven 3.X
- ChromeDriver
Following attributes has to be set either in your global environment or JVM:
- spring.profiles.active - Set to either 'development' or 'production'. See section Spring Profiles for more details.
- log.dir - The path to store log files
- spring.datasource.jdbc.driver - The JDBC Driver
- spring.datasource.jdbc.url - The DB URL
- spring.datasource.jdbc.username - The DB username
- spring.datasource.jdbc.password - The DB password
- spring.jpa.hibernate.dialect - The dialect type of the ORM. E.g. org.hibernate.dialect.MySQLDialect
- spring.jpa.hibernate.hbm2ddl.auto - Defines how the database schema should be populated: 'create', 'create-drop', 'validate' or 'none'.
- test.app.domain - Used for integration tests. Defines the HTTP root endpoint where the application runs (E.g. http://example.com/app)
- test.user.agentid - The AgentId of the superuser context during integration testing
- test.webdriver.chrome.driver - Used by Selenium. Should be the full path to the ChromeDriver in your local environment.
During application runtime either one or more profiles may be active within the context. The behaviour may vary depending on the profile configuration.
The application is pre-defined with two default profiles: development and production.
Activate the development profile:
spring.profiles.active="dev"
Activate the production profile:
spring.profiles.active="production"
The production profile differentiates from the development behaviour in the following way:
spring.jpa.hibernate.hbm2ddl.auto="none"
A pre-defined profile is configured in the pom.xml
. The profile is mainly for usage within Autonuomous Testing/Continuous Integration pipelines.
spring.profiles.active="dev"
spring.datasource.jdbc.driver="org.hsqldb.jdbcDriver"
spring.datasource.jdbc.url="jdbc:hsqldb:hsql://localhost/xdb"
spring.datasource.jdbc.username="sa"
spring.datasource.jdbc.password=""
spring.jpa.hibernate.dialect="org.hibernate.dialect.HSQLDialect"
spring.jpa.hibernate.hbm2ddl.auto="create-drop"
test.app.domain="http://localhost:9090/app"
test.user.agentid="${env.TEST_USER_AGENTID}"
test.webdriver.chrome.driver="${env.TEST_WEBDRIVER_CHROME_DRIVER}"
log.dir="${project.basedir}/log"
Run following command to verify and execute all tests:
mvn verify
Tests the behaviours of single components according to the SOLID pattern.
Directory location: src/test/java
mvn test
The integration tests covers more complex behaviours and dependencies between components. E.g. BDD, API and database tests.
Direcotry location: src/integration-test/java
mvn integration-test
Adds Eclipse Dynamic Web support to the project:
mvn eclipse:eclipse
First build and package the project with maven:
docker run -it --rm -v "$PWD":/app -w /app maven:3.3-jdk-8 mvn clean package
Build your image:
docker build --rm=false -t app .
Run the recently built image:
docker run --rm -p 8080:8080 app
Enter following URL in your browser:
http://localhost:8080/app