Я создал простое приложение JHipster с этими настройками на .yo-rc.json
:
{
"generator-jhipster": {
"promptValues": {
"packageName": "com.jhtest",
"nativeLanguage": "es"
},
"jhipsterVersion": "5.5.0",
"applicationType": "monolith",
"baseName": "jhTest",
"packageName": "com.jhtest",
"packageFolder": "com/jhtest",
"serverPort": "8080",
"authenticationType": "jwt",
"cacheProvider": "ehcache",
"enableHibernateCache": true,
"websocket": false,
"databaseType": "sql",
"devDatabaseType": "h2Disk",
"prodDatabaseType": "oracle",
"searchEngine": false,
"messageBroker": false,
"serviceDiscoveryType": false,
"buildTool": "maven",
"enableSwaggerCodegen": false,
"jwtSecretKey": "...",
"clientFramework": "angularX",
"useSass": true,
"clientPackageManager": "npm",
"testFrameworks": [],
"jhiPrefix": "jhi",
"enableTranslation": true,
"nativeLanguage": "es",
"languages": [
"es",
"en"
]
}
}
Я добавил spring-boot-starter-tomcat
в pom.xml в профиле продукта:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
и ServletInitializer
класс:
package com.jhtest;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
public class ServletInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(JhTestApp.class);
}
}
Я запустил mvnw -Pprod package
, чтобы упаковать проект в файл .war. Я попытался запустить jh-test.war.original
(это рекомендовано документацией JHipster) на Tomcat (v8.5).
Во время запуска Tomcat я получаю эту ошибку:
2018-11-05 12:10:06.657 WARN 2124 --- [ost-startStop-1] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.ryantenney.metrics.spring.config.annotation.DelegatingMetricsConfiguration': Unsatisfied dependency expressed through method 'setMetricsConfigurers' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'metricsConfiguration': Invocation of init method failed; nested exception is java.lang.IllegalStateException: cannot use setMetricsTrackerFactory() and setMetricRegistry() together
2018-11-05 12:10:06.683 ERROR 2124 --- [ost-startStop-1] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.ryantenney.metrics.spring.config.annotation.DelegatingMetricsConfiguration': Unsatisfied dependency expressed through method 'setMetricsConfigurers' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'metricsConfiguration': Invocation of init method failed; nested exception is java.lang.IllegalStateException: cannot use setMetricsTrackerFactory() and setMetricRegistry() together
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:666)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:372)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1341)
[...]
Caused by: java.lang.IllegalStateException: cannot use setMetricsTrackerFactory() and setMetricRegistry() together
at com.zaxxer.hikari.HikariConfig.setMetricsTrackerFactory(HikariConfig.java:710)
at com.zaxxer.hikari.HikariDataSource.setMetricsTrackerFactory(HikariDataSource.java:255)
at com.jhtest.config.MetricsConfiguration.init(MetricsConfiguration.java:91)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[...]