automatic project update

This commit is contained in:
Julien Dubois 2017-02-02 11:58:17 +01:00
parent 04782ad5a3
commit 5b581be2b6
127 changed files with 8438 additions and 2811 deletions

5
.gitignore vendored
View File

@ -2,6 +2,8 @@
# Project Specific
######################
/target/www/**
/src/test/javascript/coverage/
/src/test/javascript/PhantomJS*/
######################
# Node
@ -9,6 +11,7 @@
node/
node_tmp/
node_modules/
npm-debug.log.*
######################
# SASS
@ -31,6 +34,7 @@ local.properties
.classpath
.settings/
.loadpath
.factorypath
/src/main/resources/rebel.xml
# External tool builders
@ -70,6 +74,7 @@ target/
# Gradle
######################
.gradle/
build/
######################
# Package Files

View File

@ -4,7 +4,7 @@ services:
- docker
language: java
node_js:
- "6.9.1"
- "6.9.4"
jdk:
- oraclejdk8
sudo: false

View File

@ -24,11 +24,13 @@
"en"
],
"serverPort": 8080,
"jhipsterVersion": "3.12.2",
"jhipsterVersion": "4.0.0",
"enableSocialSignIn": false,
"useSass": false,
"jhiPrefix": "jhi",
"messageBroker": false,
"serviceDiscoveryType": false
"serviceDiscoveryType": false,
"clientPackageManager": "yarn",
"clientFramework": "angular1"
}
}

39
Jenkinsfile vendored
View File

@ -1,48 +1,55 @@
#!/usr/bin/env groovy
node {
stage('checkout') {
checkout scm
}
// uncomment these 2 lines and edit the name 'node-4.6.0' according to what you choose in configuration
// def nodeHome = tool name: 'node-4.6.0', type: 'jenkins.plugins.nodejs.tools.NodeJSInstallation'
// env.PATH = "${nodeHome}/bin:${env.PATH}"
stage('check tools') {
sh "node -v"
sh "npm -v"
sh "bower -v"
sh "gulp -v"
}
stage('npm install') {
sh "npm install"
stage('check java') {
sh "java -version"
}
stage('clean') {
sh "./mvnw clean"
}
stage('install tools') {
sh "./mvnw com.github.eirslett:frontend-maven-plugin:install-node-and-yarn -DnodeVersion=v6.9.4 -DyarnVersion=v0.19.1"
}
stage('yarn install') {
sh "./mvnw com.github.eirslett:frontend-maven-plugin:yarn"
}
stage('backend tests') {
try {
sh "./mvnw test"
} catch(err) {
throw err
} finally {
step([$class: 'JUnitResultArchiver', testResults: '**/target/surefire-reports/TEST-*.xml'])
junit '**/target/surefire-reports/TEST-*.xml'
}
}
stage('frontend tests') {
try {
sh "gulp test"
sh "./mvnw com.github.eirslett:frontend-maven-plugin:gulp -Dfrontend.gulp.arguments=test"
} catch(err) {
throw err
} finally {
step([$class: 'JUnitResultArchiver', testResults: '**/target/test-results/karma/TESTS-*.xml'])
junit '**/target/test-results/karma/TESTS-*.xml'
}
}
stage('packaging') {
sh "./mvnw package -Pprod -DskipTests"
archiveArtifacts artifacts: '**/target/*.war', fingerprint: true
}
// Uncomment the following block to add Sonar analysis.
/*stage('quality analysis') {
withSonarQubeEnv('Sonar Server') {
sh "./mvnw sonar:sonar"
}
}*/
}

View File

@ -1,21 +1,22 @@
# jhipsterSampleApplication
This application was generated using JHipster 3.12.1, you can find documentation and help at [https://jhipster.github.io/documentation-archive/v3.12.1](https://jhipster.github.io/documentation-archive/v3.12.1).
This application was generated using JHipster 3.12.2, you can find documentation and help at [https://jhipster.github.io/documentation-archive/v3.12.2](https://jhipster.github.io/documentation-archive/v3.12.2).
## Development
Before you can build this project, you must install and configure the following dependencies on your machine:
1. [Node.js][]: We use Node to run a development web server and build the project.
Depending on your system, you can install Node either from source or as a pre-packaged bundle.
2. [Yarn][]: We use Yarn to manage Node dependencies.
Depending on your system, you can install Yarn either from source or as a pre-packaged bundle.
After installing Node, you should be able to run the following command to install development tools (like
[Bower][] and [BrowserSync][]). You will only need to run this command when dependencies change in package.json.
After installing Node, you should be able to run the following command to install development tools.
You will only need to run this command when dependencies change in `package.json`.
npm install
yarn install
We use [Gulp][] as our build system. Install the Gulp command-line tool globally with:
npm install -g gulp-cli
yarn global add gulp-cli
Run the following commands in two separate terminals to create a blissful development experience where your browser
auto-refreshes when files change on your hard drive.
@ -23,12 +24,13 @@ auto-refreshes when files change on your hard drive.
./mvnw
gulp
Bower is used to manage CSS and JavaScript dependencies used in this application. You can upgrade dependencies by
[Bower][] is used to manage CSS and JavaScript dependencies used in this application. You can upgrade dependencies by
specifying a newer version in `bower.json`. You can also run `bower update` and `bower install` to manage dependencies.
Add the `-h` flag on any command to see how you can use it. For example, `bower update -h`.
For further instructions on how to develop with JHipster, have a look at [Using JHipster in development][].
## Building for production
To optimize the jhipsterSampleApplication application for production, run:
@ -93,19 +95,22 @@ For more information refer to [Using Docker and Docker-Compose][], this page als
To set up a CI environment, consult the [Setting up Continuous Integration][] page.
[JHipster Homepage and latest documentation]: https://jhipster.github.io
[JHipster 3.12.1 archive]: https://jhipster.github.io/documentation-archive/v3.12.1
[JHipster 3.12.2 archive]: https://jhipster.github.io/documentation-archive/v3.12.2
[Using JHipster in development]: https://jhipster.github.io/documentation-archive/v3.12.1/development/
[Using Docker and Docker-Compose]: https://jhipster.github.io/documentation-archive/v3.12.1/docker-compose
[Using JHipster in production]: https://jhipster.github.io/documentation-archive/v3.12.1/production/
[Running tests page]: https://jhipster.github.io/documentation-archive/v3.12.1/running-tests/
[Setting up Continuous Integration]: https://jhipster.github.io/documentation-archive/v3.12.1/setting-up-ci/
[Using JHipster in development]: https://jhipster.github.io/documentation-archive/v3.12.2/development/
[Using Docker and Docker-Compose]: https://jhipster.github.io/documentation-archive/v3.12.2/docker-compose
[Using JHipster in production]: https://jhipster.github.io/documentation-archive/v3.12.2/production/
[Running tests page]: https://jhipster.github.io/documentation-archive/v3.12.2/running-tests/
[Setting up Continuous Integration]: https://jhipster.github.io/documentation-archive/v3.12.2/setting-up-ci/
[Gatling]: http://gatling.io/
[Node.js]: https://nodejs.org/
[Yarn]: https://yarnpkg.org/
[Bower]: http://bower.io/
[Gulp]: http://gulpjs.com/
[BrowserSync]: http://www.browsersync.io/
[Karma]: http://karma-runner.github.io/
[Jasmine]: http://jasmine.github.io/2.0/introduction.html
[Protractor]: https://angular.github.io/protractor/
[Leaflet]: http://leafletjs.com/
[DefinitelyTyped]: http://definitelytyped.org/

View File

@ -1,4 +1,4 @@
// Generated on 2016-12-19 using generator-jhipster 3.12.2
// Generated on 2017-02-02 using generator-jhipster 4.0.0
'use strict';
var gulp = require('gulp'),

View File

@ -14,7 +14,7 @@
"eslint-config-angular": "0.5.0",
"eslint-plugin-angular": "1.3.1",
"event-stream": "3.3.4",
"generator-jhipster": "3.12.2",
"generator-jhipster": "4.0.0",
"gulp": "3.9.1",
"gulp-angular-filesort": "1.1.1",
"gulp-angular-templatecache": "2.0.0",

215
pom.xml
View File

@ -5,8 +5,8 @@
<parent>
<artifactId>spring-boot-starter-parent</artifactId>
<groupId>org.springframework.boot</groupId>
<version>1.4.2.RELEASE</version>
<relativePath/>
<version>1.4.4.RELEASE</version>
<relativePath />
</parent>
<groupId>io.github.jhipster.sample</groupId>
@ -25,65 +25,78 @@
<awaitility.version>1.7.0</awaitility.version>
<commons-io.version>2.5</commons-io.version>
<commons-lang.version>3.4</commons-lang.version>
<frontend-maven-plugin.version>1.2</frontend-maven-plugin.version>
<gatling.version>2.2.0</gatling.version>
<frontend-maven-plugin.version>1.3</frontend-maven-plugin.version>
<gatling-maven-plugin.version>2.2.0</gatling-maven-plugin.version>
<gatling.version>2.2.0</gatling.version>
<hibernate-validator.version>5.3.3.Final</hibernate-validator.version>
<hibernate.version>5.2.4.Final</hibernate.version>
<hikaricp.version>2.4.6</hikaricp.version>
<jacoco-maven-plugin.version>0.7.7.201606060606</jacoco-maven-plugin.version>
<java.version>1.8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<jcache.version>1.0.0</jcache.version>
<javax.inject.version>1</javax.inject.version>
<liquibase.version>3.5.3</liquibase.version>
<liquibase-slf4j.version>2.0.0</liquibase-slf4j.version>
<jhipster.server.version>1.0.0</jhipster.server.version>
<liquibase-hibernate5.version>3.6</liquibase-hibernate5.version>
<mapstruct.version>1.1.0.Final</mapstruct.version>
<liquibase-slf4j.version>2.0.0</liquibase-slf4j.version>
<liquibase.version>3.5.3</liquibase.version>
<logstash-logback-encoder.version>4.7</logstash-logback-encoder.version>
<m2e.apt.activation>jdt_apt</m2e.apt.activation>
<maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format>
<mapstruct.version>1.1.0.Final</mapstruct.version>
<maven-enforcer-plugin.version>1.4.1</maven-enforcer-plugin.version>
<maven-resources-plugin.version>3.0.1</maven-resources-plugin.version>
<sortpom-maven-plugin.version>2.5.0</sortpom-maven-plugin.version>
<maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<metrics-spring.version>3.1.3</metrics-spring.version>
<prometheus-simpleclient.version>0.0.18</prometheus-simpleclient.version>
<logstash-logback-encoder.version>4.7</logstash-logback-encoder.version>
<run.addResources>false</run.addResources>
<spring-security.version>4.1.3.RELEASE</spring-security.version>
<springfox.version>2.6.1</springfox.version>
<node.version>v6.9.4</node.version>
<!-- These remain empty unless the corresponding profile is active -->
<profile.no-liquibase />
<profile.swagger />
<!-- Sonar properties -->
<project.testresult.directory>${project.build.directory}/test-results</project.testresult.directory>
<run.addResources>false</run.addResources>
<sonar-maven-plugin.version>3.2</sonar-maven-plugin.version>
<jacoco-maven-plugin.version>0.7.7.201606060606</jacoco-maven-plugin.version>
<sonar.exclusions>src/main/webapp/content/**/*.*, src/main/webapp/bower_components/**/*.*, src/main/webapp/i18n/*.js, target/www/**/*.*</sonar.exclusions>
<sonar.issue.ignore.multicriteria>S3437,UndocumentedApi,BoldAndItalicTagsCheck</sonar.issue.ignore.multicriteria>
<!-- Rule https://sonarqube.com/coding_rules#rule_key=squid%3AS3437 is ignored, as a JPA-managed field cannot be transient -->
<sonar.issue.ignore.multicriteria.S3437.ruleKey>squid:S3437</sonar.issue.ignore.multicriteria.S3437.ruleKey>
<sonar.issue.ignore.multicriteria.S3437.resourceKey>src/main/java/**/*</sonar.issue.ignore.multicriteria.S3437.resourceKey>
<!-- Rule http://sonarqube.com/coding_rules#rule_key=squid%3AUndocumentedApi is ignored, as we want to follow "clean code" guidelines and classes, methods and arguments names should be self-explanatory -->
<sonar.issue.ignore.multicriteria.UndocumentedApi.ruleKey>squid:UndocumentedApi</sonar.issue.ignore.multicriteria.UndocumentedApi.ruleKey>
<sonar.issue.ignore.multicriteria.UndocumentedApi.resourceKey>src/main/java/**/*</sonar.issue.ignore.multicriteria.UndocumentedApi.resourceKey>
<!-- Rule https://sonarqube.com/coding_rules#rule_key=Web%3ABoldAndItalicTagsCheck is ignored. Even if we agree that using the "i" tag is an awful practice, this is what is recommended by http://fontawesome.io/examples/ -->
<sonar.issue.ignore.multicriteria.BoldAndItalicTagsCheck.ruleKey>Web:BoldAndItalicTagsCheck</sonar.issue.ignore.multicriteria.BoldAndItalicTagsCheck.ruleKey>
<sonar.issue.ignore.multicriteria.BoldAndItalicTagsCheck.resourceKey>src/main/webapp/app/**/*.*</sonar.issue.ignore.multicriteria.BoldAndItalicTagsCheck.resourceKey>
<sonar.issue.ignore.multicriteria.BoldAndItalicTagsCheck.ruleKey>Web:BoldAndItalicTagsCheck</sonar.issue.ignore.multicriteria.BoldAndItalicTagsCheck.ruleKey>
<!-- Rule https://sonarqube.com/coding_rules#rule_key=squid%3AS3437 is ignored, as a JPA-managed field cannot be transient -->
<sonar.issue.ignore.multicriteria.S3437.resourceKey>src/main/java/**/*</sonar.issue.ignore.multicriteria.S3437.resourceKey>
<sonar.issue.ignore.multicriteria.S3437.ruleKey>squid:S3437</sonar.issue.ignore.multicriteria.S3437.ruleKey>
<!-- Rule http://sonarqube.com/coding_rules#rule_key=squid%3AUndocumentedApi is ignored, as we want to follow "clean code" guidelines and classes, methods and arguments names should be self-explanatory -->
<sonar.issue.ignore.multicriteria.UndocumentedApi.resourceKey>src/main/java/**/*</sonar.issue.ignore.multicriteria.UndocumentedApi.resourceKey>
<sonar.issue.ignore.multicriteria.UndocumentedApi.ruleKey>squid:UndocumentedApi</sonar.issue.ignore.multicriteria.UndocumentedApi.ruleKey>
<sonar.java.codeCoveragePlugin>jacoco</sonar.java.codeCoveragePlugin>
<sonar.jacoco.itReportPath>${project.testresult.directory}/coverage/jacoco/jacoco-it.exec</sonar.jacoco.itReportPath>
<sonar.jacoco.reportPath>${project.testresult.directory}/coverage/jacoco/jacoco.exec</sonar.jacoco.reportPath>
<sonar.java.codeCoveragePlugin>jacoco</sonar.java.codeCoveragePlugin>
<sonar.javascript.jstestdriver.reportsPath>${project.testresult.directory}/karma</sonar.javascript.jstestdriver.reportsPath>
<!-- For Sonar < 6.2 -->
<sonar.javascript.lcov.reportPath>${project.testresult.directory}/coverage/report-lcov/lcov.info</sonar.javascript.lcov.reportPath>
<!-- For Sonar >= 6.2 -->
<sonar.javascript.lcov.reportPaths>${project.testresult.directory}/coverage/report-lcov/lcov.info</sonar.javascript.lcov.reportPaths>
<sonar.sources>${project.basedir}/src/main/</sonar.sources>
<sonar.surefire.reportsPath>${project.testresult.directory}/surefire-reports</sonar.surefire.reportsPath>
<sonar.tests>${project.basedir}/src/test/</sonar.tests>
<!-- These remain empty unless the corresponding profile is active -->
<profile.no-liquibase></profile.no-liquibase>
<profile.swagger></profile.swagger>
<sortpom-maven-plugin.version>2.5.0</sortpom-maven-plugin.version>
<!-- Spring properties -->
<springfox.version>2.6.1</springfox.version>
<yarn.version>v0.19.1</yarn.version>
</properties>
<dependencies>
<dependency>
<groupId>io.github.jhipster</groupId>
<artifactId>jhipster</artifactId>
<version>${jhipster.server.version}</version>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-core</artifactId>
@ -93,10 +106,6 @@
<artifactId>metrics-annotation</artifactId>
<version>${dropwizard-metrics.version}</version>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-graphite</artifactId>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-healthchecks</artifactId>
@ -127,21 +136,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient</artifactId>
<version>${prometheus-simpleclient.version}</version>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_servlet</artifactId>
<version>${prometheus-simpleclient.version}</version>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_dropwizard</artifactId>
<version>${prometheus-simpleclient.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-hibernate5</artifactId>
@ -253,11 +247,6 @@
<artifactId>cache-api</artifactId>
<version>${jcache.version}</version>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>${javax.inject.version}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
@ -284,7 +273,7 @@
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.3.3.Final</version>
<version>${hibernate-validator.version}</version>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
@ -678,8 +667,8 @@
<artifactId>frontend-maven-plugin</artifactId>
<versionRange>${frontend-maven-plugin.version}</versionRange>
<goals>
<goal>install-node-and-npm</goal>
<goal>npm</goal>
<goal>install-node-and-yarn</goal>
<goal>yarn</goal>
<goal>bower</goal>
<goal>gulp</goal>
</goals>
@ -761,25 +750,57 @@
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
<configuration>
<filesets>
<fileset>
<directory>target/www/</directory>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warSourceDirectory>target/www/</warSourceDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
</configuration>
<executions>
<execution>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>${frontend-maven-plugin.version}</version>
<executions>
<execution>
<id>install node and npm</id>
<id>install node and yarn</id>
<goals>
<goal>install-node-and-npm</goal>
<goal>install-node-and-yarn</goal>
</goals>
<configuration>
<nodeVersion>v6.9.1</nodeVersion>
<npmVersion>3.10.9</npmVersion>
<nodeVersion>${node.version}</nodeVersion>
<yarnVersion>${yarn.version}</yarnVersion>
</configuration>
</execution>
<execution>
<id>npm install</id>
<id>yarn install</id>
<goals>
<goal>npm</goal>
<goal>yarn</goal>
</goals>
<configuration>
<arguments>install</arguments>
@ -815,38 +836,6 @@
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
<configuration>
<filesets>
<fileset>
<directory>target/www/</directory>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warSourceDirectory>target/www/</warSourceDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
</configuration>
<executions>
<execution>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
@ -951,6 +940,44 @@
<spring.profiles.active>dev,swagger</spring.profiles.active>
</properties>
</profile>
<profile>
<!--
Profile for monitoring the application with Graphite.
-->
<id>graphite</id>
<dependencies>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-graphite</artifactId>
</dependency>
</dependencies>
</profile>
<profile>
<!--
Profile for monitoring the application with Prometheus.
-->
<id>prometheus</id>
<properties>
<prometheus-simpleclient.version>0.0.18</prometheus-simpleclient.version>
</properties>
<dependencies>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient</artifactId>
<version>${prometheus-simpleclient.version}</version>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_servlet</artifactId>
<version>${prometheus-simpleclient.version}</version>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_dropwizard</artifactId>
<version>${prometheus-simpleclient.version}</version>
</dependency>
</dependencies>
</profile>
<profile>
<!--
Profile for applying IDE-specific configuration.

View File

@ -1,11 +1,11 @@
FROM openjdk:8-jre-alpine
ENV JHIPSTER_SLEEP 0
ENV SPRING_OUTPUT_ANSI_ENABLED=ALWAYS \
JHIPSTER_SLEEP=0
# add directly the war
ADD *.war /app.war
RUN sh -c 'touch /app.war'
VOLUME /tmp
EXPOSE 8080
CMD echo "The application will start in ${JHIPSTER_SLEEP}s..." && \

View File

@ -11,4 +11,4 @@ services:
- MYSQL_DATABASE=jhipstersampleapplication
ports:
- 3306:3306
command: mysqld --lower_case_table_names=1 --skip-ssl
command: mysqld --lower_case_table_names=1 --skip-ssl --character_set_server=utf8

View File

@ -2,7 +2,7 @@ version: '2'
services:
jhipstersampleapplication-sonar:
container_name: jhipstersampleapplication-sonar
image: sonarqube:6.1-alpine
image: sonarqube:6.2-alpine
ports:
- 9000:9000
- 9092:9092

View File

@ -1,8 +1,8 @@
package io.github.jhipster.sample;
import io.github.jhipster.sample.config.Constants;
import io.github.jhipster.sample.config.DefaultProfileUtil;
import io.github.jhipster.sample.config.JHipsterProperties;
import io.github.jhipster.config.JHipsterConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -15,21 +15,23 @@ import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.Environment;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Arrays;
import java.util.Collection;
@ComponentScan
@EnableAutoConfiguration(exclude = { MetricFilterAutoConfiguration.class, MetricRepositoryAutoConfiguration.class })
@EnableConfigurationProperties({ JHipsterProperties.class, LiquibaseProperties.class })
@EnableAutoConfiguration(exclude = {MetricFilterAutoConfiguration.class, MetricRepositoryAutoConfiguration.class})
@EnableConfigurationProperties(LiquibaseProperties.class)
public class JhipsterSampleApplicationApp {
private static final Logger log = LoggerFactory.getLogger(JhipsterSampleApplicationApp.class);
@Inject
private Environment env;
private final Environment env;
public JhipsterSampleApplicationApp(Environment env) {
this.env = env;
}
/**
* Initializes jhipsterSampleApplication.
@ -40,13 +42,12 @@ public class JhipsterSampleApplicationApp {
*/
@PostConstruct
public void initApplication() {
log.info("Running with Spring profile(s) : {}", Arrays.toString(env.getActiveProfiles()));
Collection<String> activeProfiles = Arrays.asList(env.getActiveProfiles());
if (activeProfiles.contains(Constants.SPRING_PROFILE_DEVELOPMENT) && activeProfiles.contains(Constants.SPRING_PROFILE_PRODUCTION)) {
if (activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT) && activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_PRODUCTION)) {
log.error("You have misconfigured your application! It should not run " +
"with both the 'dev' and 'prod' profiles at the same time.");
}
if (activeProfiles.contains(Constants.SPRING_PROFILE_DEVELOPMENT) && activeProfiles.contains(Constants.SPRING_PROFILE_CLOUD)) {
if (activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT) && activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_CLOUD)) {
log.error("You have misconfigured your application! It should not" +
"run with both the 'dev' and 'cloud' profiles at the same time.");
}
@ -65,11 +66,12 @@ public class JhipsterSampleApplicationApp {
log.info("\n----------------------------------------------------------\n\t" +
"Application '{}' is running! Access URLs:\n\t" +
"Local: \t\thttp://localhost:{}\n\t" +
"External: \thttp://{}:{}\n----------------------------------------------------------",
"External: \thttp://{}:{}\n\t" +
"Profile(s): \t{}\n----------------------------------------------------------",
env.getProperty("spring.application.name"),
env.getProperty("server.port"),
InetAddress.getLocalHost().getHostAddress(),
env.getProperty("server.port"));
env.getProperty("server.port"),
env.getActiveProfiles());
}
}

View File

@ -1,6 +1,6 @@
package io.github.jhipster.sample.aop.logging;
import io.github.jhipster.sample.config.Constants;
import io.github.jhipster.config.JHipsterConstants;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
@ -12,7 +12,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.env.Environment;
import javax.inject.Inject;
import java.util.Arrays;
/**
@ -25,8 +24,11 @@ public class LoggingAspect {
private final Logger log = LoggerFactory.getLogger(this.getClass());
@Inject
private Environment env;
private final Environment env;
public LoggingAspect(Environment env) {
this.env = env;
}
/**
* Pointcut that matches all repositories, services and Web REST endpoints.
@ -41,7 +43,7 @@ public class LoggingAspect {
*/
@AfterThrowing(pointcut = "loggingPointcut()", throwing = "e")
public void logAfterThrowing(JoinPoint joinPoint, Throwable e) {
if (env.acceptsProfiles(Constants.SPRING_PROFILE_DEVELOPMENT)) {
if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)) {
log.error("Exception in {}.{}() with cause = \'{}\' and exception = \'{}\'", joinPoint.getSignature().getDeclaringTypeName(),
joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL", e.getMessage(), e);

View File

@ -1,83 +0,0 @@
package io.github.jhipster.sample.async;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.core.task.AsyncTaskExecutor;
public class ExceptionHandlingAsyncTaskExecutor implements AsyncTaskExecutor,
InitializingBean, DisposableBean {
private final Logger log = LoggerFactory.getLogger(ExceptionHandlingAsyncTaskExecutor.class);
private final AsyncTaskExecutor executor;
public ExceptionHandlingAsyncTaskExecutor(AsyncTaskExecutor executor) {
this.executor = executor;
}
@Override
public void execute(Runnable task) {
executor.execute(createWrappedRunnable(task));
}
@Override
public void execute(Runnable task, long startTimeout) {
executor.execute(createWrappedRunnable(task), startTimeout);
}
private <T> Callable<T> createCallable(final Callable<T> task) {
return () -> {
try {
return task.call();
} catch (Exception e) {
handle(e);
throw e;
}
};
}
private Runnable createWrappedRunnable(final Runnable task) {
return () -> {
try {
task.run();
} catch (Exception e) {
handle(e);
}
};
}
protected void handle(Exception e) {
log.error("Caught async exception", e);
}
@Override
public Future<?> submit(Runnable task) {
return executor.submit(createWrappedRunnable(task));
}
@Override
public <T> Future<T> submit(Callable<T> task) {
return executor.submit(createCallable(task));
}
@Override
public void destroy() throws Exception {
if (executor instanceof DisposableBean) {
DisposableBean bean = (DisposableBean) executor;
bean.destroy();
}
}
@Override
public void afterPropertiesSet() throws Exception {
if (executor instanceof InitializingBean) {
InitializingBean bean = (InitializingBean) executor;
bean.afterPropertiesSet();
}
}
}

View File

@ -1,4 +0,0 @@
/**
* Async helpers.
*/
package io.github.jhipster.sample.async;

View File

@ -0,0 +1,15 @@
package io.github.jhipster.sample.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
* Properties specific to JHipster.
*
* <p>
* Properties are configured in the application.yml file.
* </p>
*/
@ConfigurationProperties(prefix = "application", ignoreUnknownFields = false)
public class ApplicationProperties {
}

View File

@ -1,6 +1,7 @@
package io.github.jhipster.sample.config;
import io.github.jhipster.sample.async.ExceptionHandlingAsyncTaskExecutor;
import io.github.jhipster.async.ExceptionHandlingAsyncTaskExecutor;
import io.github.jhipster.config.JHipsterProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -13,8 +14,6 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.Executor;
import javax.inject.Inject;
@Configuration
@EnableAsync
@EnableScheduling
@ -22,8 +21,11 @@ public class AsyncConfiguration implements AsyncConfigurer {
private final Logger log = LoggerFactory.getLogger(AsyncConfiguration.class);
@Inject
private JHipsterProperties jHipsterProperties;
private final JHipsterProperties jHipsterProperties;
public AsyncConfiguration(JHipsterProperties jHipsterProperties) {
this.jHipsterProperties = jHipsterProperties;
}
@Override
@Bean(name = "taskExecutor")

View File

@ -1,6 +1,5 @@
package io.github.jhipster.sample.config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
@ -8,9 +7,7 @@ import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.*;
import javax.annotation.PreDestroy;
import javax.cache.CacheManager;
import javax.inject.Inject;
@Configuration
@EnableCaching
@ -20,13 +17,9 @@ public class CacheConfiguration {
private final Logger log = LoggerFactory.getLogger(CacheConfiguration.class);
@Inject
private CacheManager cacheManager;
@PreDestroy
public void destroy() {
log.info("Closing Cache Manager");
cacheManager.close();
public CacheConfiguration(CacheManager cacheManager) {
this.cacheManager = cacheManager;
}
}

View File

@ -1,5 +1,7 @@
package io.github.jhipster.sample.config;
import io.github.jhipster.config.JHipsterConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.config.java.AbstractCloudConfig;
@ -8,7 +10,7 @@ import org.springframework.context.annotation.*;
import javax.sql.DataSource;
@Configuration
@Profile(Constants.SPRING_PROFILE_CLOUD)
@Profile(JHipsterConstants.SPRING_PROFILE_CLOUD)
public class CloudDatabaseConfiguration extends AbstractCloudConfig {
private final Logger log = LoggerFactory.getLogger(CloudDatabaseConfiguration.class);

View File

@ -7,18 +7,6 @@ public final class Constants {
//Regex for acceptable logins
public static final String LOGIN_REGEX = "^[_'.@A-Za-z0-9-]*$";
// Spring profiles for development, test and production, see http://jhipster.github.io/profiles/
public static final String SPRING_PROFILE_DEVELOPMENT = "dev";
public static final String SPRING_PROFILE_TEST = "test";
public static final String SPRING_PROFILE_PRODUCTION = "prod";
// Spring profile used when deploying with Spring Cloud (used when deploying to CloudFoundry)
public static final String SPRING_PROFILE_CLOUD = "cloud";
// Spring profile used when deploying to Heroku
public static final String SPRING_PROFILE_HEROKU = "heroku";
// Spring profile used to disable swagger
public static final String SPRING_PROFILE_SWAGGER = "swagger";
// Spring profile used to disable running liquibase
public static final String SPRING_PROFILE_NO_LIQUIBASE = "no-liquibase";
public static final String SYSTEM_ACCOUNT = "system";

View File

@ -1,22 +1,24 @@
package io.github.jhipster.sample.config;
import io.github.jhipster.sample.config.liquibase.AsyncSpringLiquibase;
import io.github.jhipster.config.JHipsterConstants;
import io.github.jhipster.config.liquibase.AsyncSpringLiquibase;
import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module;
import liquibase.integration.spring.SpringLiquibase;
import org.h2.tools.Server;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.liquibase.LiquibaseProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.core.env.Environment;
import org.springframework.core.task.TaskExecutor;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.inject.Inject;
import javax.sql.DataSource;
import java.sql.SQLException;
@ -28,8 +30,11 @@ public class DatabaseConfiguration {
private final Logger log = LoggerFactory.getLogger(DatabaseConfiguration.class);
@Inject
private Environment env;
private final Environment env;
public DatabaseConfiguration(Environment env) {
this.env = env;
}
/**
* Open the TCP port for the H2 database, so it is available remotely.
@ -38,22 +43,23 @@ public class DatabaseConfiguration {
* @throws SQLException if the server failed to start
*/
@Bean(initMethod = "start", destroyMethod = "stop")
@Profile(Constants.SPRING_PROFILE_DEVELOPMENT)
@Profile(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)
public Server h2TCPServer() throws SQLException {
return Server.createTcpServer("-tcp","-tcpAllowOthers");
}
@Bean
public SpringLiquibase liquibase(DataSource dataSource, LiquibaseProperties liquibaseProperties) {
public SpringLiquibase liquibase(@Qualifier("taskExecutor") TaskExecutor taskExecutor,
DataSource dataSource, LiquibaseProperties liquibaseProperties) {
// Use liquibase.integration.spring.SpringLiquibase if you don't want Liquibase to start asynchronously
SpringLiquibase liquibase = new AsyncSpringLiquibase();
SpringLiquibase liquibase = new AsyncSpringLiquibase(taskExecutor, env);
liquibase.setDataSource(dataSource);
liquibase.setChangeLog("classpath:config/liquibase/master.xml");
liquibase.setContexts(liquibaseProperties.getContexts());
liquibase.setDefaultSchema(liquibaseProperties.getDefaultSchema());
liquibase.setDropFirst(liquibaseProperties.isDropFirst());
if (env.acceptsProfiles(Constants.SPRING_PROFILE_NO_LIQUIBASE)) {
if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_NO_LIQUIBASE)) {
liquibase.setShouldRun(false);
} else {
liquibase.setShouldRun(liquibaseProperties.isEnabled());

View File

@ -1,5 +1,7 @@
package io.github.jhipster.sample.config;
import io.github.jhipster.config.JHipsterConstants;
import org.springframework.boot.SpringApplication;
import org.springframework.core.env.Environment;
@ -29,7 +31,7 @@ public final class DefaultProfileUtil {
* This cannot be set in the <code>application.yml</code> file.
* See https://github.com/spring-projects/spring-boot/issues/1219
*/
defProperties.put(SPRING_PROFILE_DEFAULT, Constants.SPRING_PROFILE_DEVELOPMENT);
defProperties.put(SPRING_PROFILE_DEFAULT, JHipsterConstants.SPRING_PROFILE_DEVELOPMENT);
app.setDefaultProperties(defProperties);
}

View File

@ -1,465 +0,0 @@
package io.github.jhipster.sample.config;
import javax.validation.constraints.NotNull;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.web.cors.CorsConfiguration;
/**
* Properties specific to JHipster.
*
* <p>
* Properties are configured in the application.yml file.
* </p>
*/
@ConfigurationProperties(prefix = "jhipster", ignoreUnknownFields = false)
public class JHipsterProperties {
private final Async async = new Async();
private final Http http = new Http();
private final Cache cache = new Cache();
private final Mail mail = new Mail();
private final Security security = new Security();
private final Swagger swagger = new Swagger();
private final Metrics metrics = new Metrics();
private final CorsConfiguration cors = new CorsConfiguration();
private final Ribbon ribbon = new Ribbon();
public Async getAsync() {
return async;
}
public Http getHttp() {
return http;
}
public Cache getCache() {
return cache;
}
public Mail getMail() {
return mail;
}
public Security getSecurity() {
return security;
}
public Swagger getSwagger() {
return swagger;
}
public Metrics getMetrics() {
return metrics;
}
public CorsConfiguration getCors() {
return cors;
}
public Ribbon getRibbon() {
return ribbon;
}
public static class Async {
private int corePoolSize = 2;
private int maxPoolSize = 50;
private int queueCapacity = 10000;
public int getCorePoolSize() {
return corePoolSize;
}
public void setCorePoolSize(int corePoolSize) {
this.corePoolSize = corePoolSize;
}
public int getMaxPoolSize() {
return maxPoolSize;
}
public void setMaxPoolSize(int maxPoolSize) {
this.maxPoolSize = maxPoolSize;
}
public int getQueueCapacity() {
return queueCapacity;
}
public void setQueueCapacity(int queueCapacity) {
this.queueCapacity = queueCapacity;
}
}
public static class Http {
private final Cache cache = new Cache();
public Cache getCache() {
return cache;
}
public static class Cache {
private int timeToLiveInDays = 1461;
public int getTimeToLiveInDays() {
return timeToLiveInDays;
}
public void setTimeToLiveInDays(int timeToLiveInDays) {
this.timeToLiveInDays = timeToLiveInDays;
}
}
}
public static class Cache {
private final Ehcache ehcache = new Ehcache();
public Ehcache getEhcache() {
return ehcache;
}
public static class Ehcache {
private String maxBytesLocalHeap = "16M";
public String getMaxBytesLocalHeap() {
return maxBytesLocalHeap;
}
public void setMaxBytesLocalHeap(String maxBytesLocalHeap) {
this.maxBytesLocalHeap = maxBytesLocalHeap;
}
}
}
public static class Mail {
private String from = "jhipsterSampleApplication@localhost";
private String baseUrl = "";
public String getFrom() {
return from;
}
public void setFrom(String from) {
this.from = from;
}
public String getBaseUrl() {
return baseUrl;
}
public void setBaseUrl(String baseUrl) {
this.baseUrl = baseUrl;
}
}
public static class Security {
private final RememberMe rememberMe = new RememberMe();
public RememberMe getRememberMe() {
return rememberMe;
}
public static class RememberMe {
@NotNull
private String key;
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
}
}
public static class Swagger {
private String title = "jhipsterSampleApplication API";
private String description = "jhipsterSampleApplication API documentation";
private String version = "0.0.1";
private String termsOfServiceUrl;
private String contactName;
private String contactUrl;
private String contactEmail;
private String license;
private String licenseUrl;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getTermsOfServiceUrl() {
return termsOfServiceUrl;
}
public void setTermsOfServiceUrl(String termsOfServiceUrl) {
this.termsOfServiceUrl = termsOfServiceUrl;
}
public String getContactName() {
return contactName;
}
public void setContactName(String contactName) {
this.contactName = contactName;
}
public String getContactUrl() {
return contactUrl;
}
public void setContactUrl(String contactUrl) {
this.contactUrl = contactUrl;
}
public String getContactEmail() {
return contactEmail;
}
public void setContactEmail(String contactEmail) {
this.contactEmail = contactEmail;
}
public String getLicense() {
return license;
}
public void setLicense(String license) {
this.license = license;
}
public String getLicenseUrl() {
return licenseUrl;
}
public void setLicenseUrl(String licenseUrl) {
this.licenseUrl = licenseUrl;
}
}
public static class Metrics {
private final Jmx jmx = new Jmx();
private final Graphite graphite = new Graphite();
private final Prometheus prometheus = new Prometheus();
private final Logs logs = new Logs();
public Jmx getJmx() {
return jmx;
}
public Graphite getGraphite() {
return graphite;
}
public Prometheus getPrometheus() {
return prometheus;
}
public Logs getLogs() {
return logs;
}
public static class Jmx {
private boolean enabled = true;
public boolean isEnabled() {
return enabled;
}
public void setEnabled(boolean enabled) {