我在.yo-rc.json
上使用以下设置构建了一个简单的JHipster应用程序:
{
"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文件。我试图在Tomcat(v8.5)上运行jh-test.war.original
(JHipster文档建议使用此版本)。
在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)
[...]