在使用spring boot创建fatJar时,它似乎失败了,因为嵌入式的tomcat bean无法初始化。我在Spring Boot中使用Vaadin 12,但似乎仍然有问题。我还确保没有其他进程在IntelliJ中使用该端口,并且还尝试使用管理特权运行该端口,但结果仍然相同。
运行jar文件时记录:
C:\Users\forne\Desktop>java -jar passcheckerserver-0.5-ALPHA.jar
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot ::
2019-02-20 21:23:41.094 INFO 1888 --- [ main] o.s.boot.SpringApplication : Starting application on LEO-DESKTOP with PID 1888 (started by forne in C:\Users\forne\Desktop)
2019-02-20 21:23:41.105 INFO 1888 --- [ main] o.s.boot.SpringApplication : No active profile set, falling back to default profiles: default
2019-02-20 21:23:42.165 INFO 1888 --- [ main] o.s.core.annotation.AnnotationUtils : Failed to introspect annotations on class org.springframework.boot.autoconfigure.web.embedded.EmbeddedWebServerFactoryCustomizerAutoConfiguration$JettyWebServerFactoryCustomizerConfiguration$$EnhancerBySpringCGLIB$$7846e955: java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
2019-02-20 21:23:42.165 WARN 1888 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tomcatServletWebServerFactory' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryConfiguration$EmbeddedTomcat.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.embedded.EmbeddedWebServerFactoryCustomizerAutoConfiguration$JettyWebServerFactoryCustomizerConfiguration': Initialization of bean failed; nested exception is java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
2019-02-20 21:23:42.171 INFO 1888 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-02-20 21:23:42.179 ERROR 1888 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tomcatServletWebServerFactory' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryConfiguration$EmbeddedTomcat.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.embedded.EmbeddedWebServerFactoryCustomizerAutoConfiguration$JettyWebServerFactoryCustomizerConfiguration': Initialization of bean failed; nested exception is java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:157) ~[passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:540) ~[passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142) ~[passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) [passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) [passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) [passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) [passcheckerserver-0.5-ALPHA.jar:na]
at tk.leoforney.passcheckerserver.Main.main(Main.java:25) [classes!/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Unknown Source) ~[na:na]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) [passcheckerserver-0.5-ALPHA.jar:na]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tomcatServletWebServerFactory' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryConfiguration$EmbeddedTomcat.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.embedded.EmbeddedWebServerFactoryCustomizerAutoConfiguration$JettyWebServerFactoryCustomizerConfiguration': Initialization of bean failed; nested exception is java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:584) ~[passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498) ~[passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204) ~[passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.getWebServerFactory(ServletWebServerApplicationContext.java:216) ~[passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:180) ~[passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:154) ~[passcheckerserver-0.5-ALPHA.jar:na]
... 16 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.embedded.EmbeddedWebServerFactoryCustomizerAutoConfiguration$JettyWebServerFactoryCustomizerConfiguration': Initialization of bean failed; nested exception is java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:584) ~[passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498) ~[passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:392) ~[passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1288) ~[passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1127) ~[passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:538) ~[passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498) ~[passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:602) ~[passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.boot.web.server.WebServerFactoryCustomizerBeanPostProcessor.getWebServerFactoryCustomizerBeans(WebServerFactoryCustomizerBeanPostProcessor.java:94) ~[passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.boot.web.server.WebServerFactoryCustomizerBeanPostProcessor.getCustomizers(WebServerFactoryCustomizerBeanPostProcessor.java:84) ~[passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.boot.web.server.WebServerFactoryCustomizerBeanPostProcessor.postProcessBeforeInitialization(WebServerFactoryCustomizerBeanPostProcessor.java:75) ~[passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.boot.web.server.WebServerFactoryCustomizerBeanPostProcessor.postProcessBeforeInitialization(WebServerFactoryCustomizerBeanPostProcessor.java:61) ~[passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:419) ~[passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1737) ~[passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:576) ~[passcheckerserver-0.5-ALPHA.jar:na]
... 24 common frames omitted
Caused by: java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
at java.base/sun.reflect.annotation.AnnotationParser.parseClassArray(Unknown Source) ~[na:na]
at java.base/sun.reflect.annotation.AnnotationParser.parseArray(Unknown Source) ~[na:na]
at java.base/sun.reflect.annotation.AnnotationParser.parseMemberValue(Unknown Source) ~[na:na]
at java.base/sun.reflect.annotation.AnnotationParser.parseAnnotation2(Unknown Source) ~[na:na]
at java.base/sun.reflect.annotation.AnnotationParser.parseAnnotations2(Unknown Source) ~[na:na]
at java.base/sun.reflect.annotation.AnnotationParser.parseAnnotations(Unknown Source) ~[na:na]
at java.base/java.lang.Class.createAnnotationData(Unknown Source) ~[na:na]
at java.base/java.lang.Class.annotationData(Unknown Source) ~[na:na]
at java.base/java.lang.Class.createAnnotationData(Unknown Source) ~[na:na]
at java.base/java.lang.Class.annotationData(Unknown Source) ~[na:na]
at java.base/java.lang.Class.getAnnotation(Unknown Source) ~[na:na]
at java.base/java.lang.reflect.AnnotatedElement.isAnnotationPresent(Unknown Source) ~[na:na]
at java.base/java.lang.Class.isAnnotationPresent(Unknown Source) ~[na:na]
at org.springframework.core.annotation.AnnotatedElementUtils.hasAnnotation(AnnotatedElementUtils.java:599) ~[passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.aop.support.annotation.AnnotationClassFilter.matches(AnnotationClassFilter.java:65) ~[passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:225) ~[passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:288) ~[passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:269) ~[passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.aop.framework.AbstractAdvisingBeanPostProcessor.isEligible(AbstractAdvisingBeanPostProcessor.java:133) ~[passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.aop.framework.AbstractAdvisingBeanPostProcessor.isEligible(AbstractAdvisingBeanPostProcessor.java:115) ~[passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.aop.framework.autoproxy.AbstractBeanFactoryAwareAdvisingPostProcessor.isEligible(AbstractBeanFactoryAwareAdvisingPostProcessor.java:70) ~[passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.aop.framework.AbstractAdvisingBeanPostProcessor.postProcessAfterInitialization(AbstractAdvisingBeanPostProcessor.java:85) ~[passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:434) ~[passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1749) ~[passcheckerserver-0.5-ALPHA.jar:na]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:576) ~[passcheckerserver-0.5-ALPHA.jar:na]
... 46 common frames omitted
Build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.jaredsburrows:gradle-license-plugin:0.8.42'
}
}
plugins {
id 'com.devsoap.vaadin-flow' version '1.0.0.RC8'
id 'org.springframework.boot' version '2.1.1.RELEASE'
}
vaadin.autoconfigure()
group 'tk.leoforney'
version '0.5-ALPHA'
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'com.jaredsburrows.license'
sourceCompatibility = 1.8
repositories {
mavenCentral()
jcenter()
maven { url "http://www.javaxt.com/maven"}
}
dependencies {
testImplementation group: 'junit', name: 'junit', version: '4.12'
implementation "com.sparkjava:spark-core:2.7.2"
implementation "org.xerial:sqlite-jdbc:3.21.0"
implementation "com.google.code.gson:gson:2.8.4"
implementation "com.vaadin:vaadin-app-layout-flow:1.0.3"
implementation "commons-codec:commons-codec:1.11"
implementation "javaxt:javaxt-core:1.9.0"
implementation "org.mongodb:mongodb-driver-sync:3.10.1"
compile ('org.vaadin.marcus:shortcut:0.3.0') {
exclude group: 'org.slf4j', module: 'slf4j-simple'
}
}
bootWar {
vaadin.productionMode=false
vaadin.submitStatistics=false
from {
configurations.compile.collect { (it.isDirectory() && it.name != "PassChecker.db") ? it : zipTree(it) }
}
}
bootJar {
vaadin.productionMode=false
vaadin.submitStatistics=false
System.out.println("BootJar reached")
manifest {
attributes ( 'Start-Class': 'tk.leoforney.passcheckerserver.Main',
'Version': version,
'Main-Class': 'org.springframework.boot.loader.JarLauncher')
}
from {
configurations.compile.collect {
System.out.println(it.getAbsoluteFile().toPath().toString())
(it.isDirectory() && it.name != "PassChecker.db") ? it : zipTree(it)
}
}
}
def getGitHash = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-parse', '--short', 'HEAD'
standardOutput = stdout
}
return stdout.toString().trim()
}
task createProperties {
doLast {
System.out.println("$projectDir")
def propFile = new File("$projectDir/out/production/resources/version.properties")
propFile.createNewFile()
propFile.withWriter { w ->
Properties p = new Properties()
p['version'] = project.version.toString()
p['vaadin'] = vaadin.version
p['productionMode'] = vaadin.productionMode.toString()
p['time'] = new Date().format('MM/dd/yyyy - HH:mm:ss')
p['hash'] = getGitHash()
p.store w, null
}
}
}
classes {
dependsOn createProperties
System.out.println("Property file created")
}
主类:
package tk.leoforney.passcheckerserver;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.ConfigurableApplicationContext;
import java.io.File;
/**
* Created by Leo on 4/30/2018.
*/
@SpringBootApplication(exclude = {org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration.class})
@ServletComponentScan
@EntityScan
public class Main {
public static String wd = System.getProperty("user.home") + File.separator + "Desktop" + File.separator + "PassCheckerServer";
public static ConfigurableApplicationContext context;
public static String[] arguments;
public static void main(String[] args) {
Runner runner = new Runner(args);
context = SpringApplication.run(Main.class, args);
arguments = args;
try {
runner.run();
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("Exited Runner");
System.exit(1);
}
}