我认为我一直遇到以下问题:泽西岛不适用于Spring Boot胖罐。解决方法应该是设置泽西依赖于POM
对requiresUnpack
。
我的POM
样子是这样的:
4.0.0 net.hagstrom demo 0.0.1-SNAPSHOT jar demo Demo project for Spring Boot org.springframework.boot spring-boot-starter-parent 1.4.3.RELEASE UTF-8 UTF-8 1.8 org.springframework.boot spring-boot-starter-jersey mysql mysql-connector-java runtime org.springframework.boot spring-boot-starter-test test org.springframework.boot spring-boot-maven-plugin org.glassfish.jersey.containers jersey-container-servlet org.glassfish.jersey.core jersey-client 1.4.3.RELEASE repackage
但是,当我尝试运行构建的JAR时,仍然出现以下错误mvn package
:
2017-01-13 10:44:28.229 ERROR 9289 --- [ost-startStop-1] o.s.b.c.embedded.tomcat.TomcatStarter : Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'org.springframework.boot.autoconfigure.jersey.JerseyAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jerseyConfig' defined in URL [jar:file:/home/mikael/Dev/Java/Java%20Programs/springBootDemo/target/demo-0.0.1-SNAPSHOT.jar!/BOOT-INF/classes!/net/hagstrom/JerseyConfig.class]: Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [net.hagstrom.JerseyConfig]: Constructor threw exception; nested exception is org.glassfish.jersey.server.internal.scanning.ResourceFinderException: java.io.FileNotFoundException: /home/mikael/Dev/Java/Java Programs/springBootDemo/target/demo-0.0.1-SNAPSHOT.jar!/BOOT-INF/classes (No such file or directory)
使用Artifacts运行我在IDE中内置的JAR可以正常工作。
用我POM
的Maven构建JAR或我的方式有问题吗?