Git Product home page Git Product logo

aws-java-app's Introduction

DevOps Java Application Template

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.

Getting Started

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

Prerequisites

Techniques used

System Properties

Following attributes has to be set either in your global environment or JVM:

Base

  • spring.profiles.active - Set to either 'development' or 'production'. See section Spring Profiles for more details.
  • log.dir - The path to store log files

Persistence

  • 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'.

Tests

  • 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.

Spring Profiles

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.

Development

Activate the development profile:

spring.profiles.active="dev"

Production

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"

Maven Profiles

Test

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"

Testing

Verify your commit

Run following command to verify and execute all tests:

mvn verify

Unit Tests

Tests the behaviours of single components according to the SOLID pattern.

Directory location: src/test/java

mvn test

Integration Tests

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

Eclipse IDE Support

Adds Eclipse Dynamic Web support to the project:

mvn eclipse:eclipse

Build and run with Docker

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

aws-java-app's People

Contributors

matake01 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.