我是春季靴子的新手。我开发了一个应用程序,它在Intellij IDE中运行没有任何问题。我想部署一个可执行jar并通过命令窗口运行它。为此,我分别在相关文件夹中应用了以下命令:
mvn clear
mvn install
请注意,在我的应用中,我使用了两个外部jar文件。其中一个是用于Oracle数据库连接的ojdbc.jar,另一个包含使用Apache Spark(cosinelsh.jar)的Scala代码。所以上面的命令应该创建一个胖jar文件。实际上,这个过程进展顺利。但是,当打算运行文件(java -jar target/mlee.jar
)时,会抛出以下错误:
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/n12017/AppData/Local/Temp/mlee-exe-jar.jar-spring-boot-libs-65763e64-4a74-4d8f-b23a-0a20f028113c/cosinelsh-1.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/n12017/IdeaProjects/LSH_USER/target/mlee-exe-jar.jar!/BOOT-INF/lib/logback-classic-1.1.9.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
Caused by: java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation (class org.slf4j.impl.Log4jLoggerFactory loaded from file:/C:/Users/n12017/AppData/Local/Temp/mlee-exe-jar.jar-spring-boot-libs-65763e64-4a74-4d8f-b23a-0a20f028113c/cosinelsh-1.0.jar). If you are using WebLogic you will need to add 'org.slf4j' to prefer-application-packages in WEB-INF/weblogic.xml Object of class [org.slf4j.impl.Log4jLoggerFactory] must be an instance of class ch.qos.logback.classic.LoggerContext
at org.springframework.util.Assert.isInstanceOf(Assert.java:346)
at org.springframework.boot.logging.logback.LogbackLoggingSystem.getLoggerContext(LogbackLoggingSystem.java:273)
at org.springframework.boot.logging.logback.LogbackLoggingSystem.beforeInitialize(LogbackLoggingSystem.java:97)
at org.springframework.boot.logging.LoggingApplicationListener.onApplicationStartingEvent(LoggingApplicationListener.java:230)
at org.springframework.boot.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:209)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:167)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:122)
at org.springframework.boot.context.event.EventPublishingRunListener.starting(EventPublishingRunListener.java:68)
at org.springframework.boot.SpringApplicationRunListeners.starting(SpringApplicationRunListeners.java:48)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151)
at softuniBlog.DemoApplication.main(DemoApplication.java:12)
... 8 more
来自stackoverflow(Favoring LogBack over Log4j in spring-boot/ security或Disable Logback in SpringBoot)中的类似问题,我尝试过类似的方法,但总是失败。
以下是依赖关系树:
--- maven-dependency-plugin:2.10:tree (default-cli) @ demo ---
[INFO] Blog:demo:jar:0.0.1-SNAPSHOT
[INFO] +- org.springframework.boot:spring-boot-starter-jdbc:jar:1.5.1.RELEASE:compile
[INFO] | +- org.apache.tomcat:tomcat-jdbc:jar:8.5.11:compile
[INFO] | | \- org.apache.tomcat:tomcat-juli:jar:8.5.11:compile
[INFO] | \- org.springframework:spring-jdbc:jar:4.3.6.RELEASE:compile
[INFO] | +- org.springframework:spring-beans:jar:4.3.6.RELEASE:compile
[INFO] | \- org.springframework:spring-tx:jar:4.3.6.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-security:jar:1.5.1.RELEASE:compile
[INFO] | +- org.springframework:spring-aop:jar:4.3.6.RELEASE:compile
[INFO] | +- org.springframework.security:spring-security-config:jar:4.2.1.RELEASE:compile
[INFO] | | \- org.springframework.security:spring-security-core:jar:4.2.1.RELEASE:compile
[INFO] | \- org.springframework.security:spring-security-web:jar:4.2.1.RELEASE:compile
[INFO] | +- org.springframework:spring-expression:jar:4.3.6.RELEASE:compile
[INFO] | \- org.springframework:spring-web:jar:4.3.6.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-thymeleaf:jar:1.5.1.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-web:jar:1.5.1.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot-starter-tomcat:jar:1.5.1.RELEASE:compile
[INFO] | | | +- org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.11:compile
[INFO] | | | +- org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.11:compile
[INFO] | | | \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.5.11:compile
[INFO] | | +- org.hibernate:hibernate-validator:jar:5.3.4.Final:compile
[INFO] | | | +- javax.validation:validation-api:jar:1.1.0.Final:compile
[INFO] | | | \- com.fasterxml:classmate:jar:1.3.3:compile
[INFO] | | \- org.springframework:spring-webmvc:jar:4.3.6.RELEASE:compile
[INFO] | +- org.thymeleaf:thymeleaf-spring4:jar:2.1.5.RELEASE:compile
[INFO] | \- nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:jar:1.4.0:compile
[INFO] | \- org.codehaus.groovy:groovy:jar:2.4.7:compile
[INFO] +- org.springframework.boot:spring-boot-starter:jar:1.5.1.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot:jar:1.5.1.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-autoconfigure:jar:1.5.1.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-logging:jar:1.5.1.RELEASE:compile
[INFO] | | +- ch.qos.logback:logback-classic:jar:1.1.9:compile
[INFO] | | | \- ch.qos.logback:logback-core:jar:1.1.9:compile
[INFO] | | +- org.slf4j:jcl-over-slf4j:jar:1.7.22:compile
[INFO] | | +- org.slf4j:jul-to-slf4j:jar:1.7.22:compile
[INFO] | | \- org.slf4j:log4j-over-slf4j:jar:1.7.22:compile
[INFO] | +- org.springframework:spring-core:jar:4.3.6.RELEASE:compile
[INFO] | \- org.yaml:snakeyaml:jar:1.17:runtime
[INFO] +- org.springframework.boot:spring-boot-devtools:jar:1.5.1.RELEASE:runtime
[INFO] +- mysql:mysql-connector-java:jar:5.1.40:runtime
[INFO] +- com.microsoft.sqlserver:mssql-jdbc:jar:6.1.0.jre7:runtime
[INFO] | \- com.microsoft.azure:azure-keyvault:jar:0.9.3:runtime
[INFO] | +- com.microsoft.azure:azure-core:jar:0.9.3:runtime
[INFO] | | +- commons-codec:commons-codec:jar:1.10:runtime
[INFO] | | +- commons-lang:commons-lang:jar:2.6:runtime
[INFO] | | +- com.sun.jersey:jersey-client:jar:1.13:runtime
[INFO] | | | \- com.sun.jersey:jersey-core:jar:1.13:runtime
[INFO] | | \- com.sun.jersey:jersey-json:jar:1.13:runtime
[INFO] | | +- org.codehaus.jettison:jettison:jar:1.1:runtime
[INFO] | | | \- stax:stax-api:jar:1.0.1:runtime
[INFO] | | +- com.sun.xml.bind:jaxb-impl:jar:2.2.3-1:runtime
[INFO] | | | \- javax.xml.bind:jaxb-api:jar:2.2.2:runtime
[INFO] | | | \- javax.xml.stream:stax-api:jar:1.0-2:runtime
[INFO] | | +- org.codehaus.jackson:jackson-core-asl:jar:1.9.2:runtime
[INFO] | | +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.2:runtime
[INFO] | | +- org.codehaus.jackson:jackson-jaxrs:jar:1.9.2:runtime
[INFO] | | \- org.codehaus.jackson:jackson-xc:jar:1.9.2:runtime
[INFO] | +- org.apache.httpcomponents:httpclient:jar:4.5.2:runtime
[INFO] | | \- org.apache.httpcomponents:httpcore:jar:4.4.6:runtime
[INFO] | +- javax.inject:javax.inject:jar:1:runtime
[INFO] | \- com.microsoft.azure:adal4j:jar:1.0.0:runtime
[INFO] | +- com.nimbusds:oauth2-oidc-sdk:jar:4.5:runtime
[INFO] | | +- net.jcip:jcip-annotations:jar:1.0:runtime
[INFO] | | +- org.apache.commons:commons-lang3:jar:3.3.1:runtime
[INFO] | | +- com.nimbusds:lang-tag:jar:1.4:runtime
[INFO] | | \- com.nimbusds:nimbus-jose-jwt:jar:3.1.2:runtime
[INFO] | | \- org.bouncycastle:bcprov-jdk15on:jar:1.51:runtime
[INFO] | \- com.google.code.gson:gson:jar:2.8.0:runtime
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:1.5.1.RELEASE:test
[INFO] | +- org.springframework.boot:spring-boot-test:jar:1.5.1.RELEASE:test
[INFO] | +- org.springframework.boot:spring-boot-test-autoconfigure:jar:1.5.1.RELEASE:test
[INFO] | +- com.jayway.jsonpath:json-path:jar:2.2.0:test
[INFO] | | \- net.minidev:json-smart:jar:2.2.1:runtime
[INFO] | | \- net.minidev:accessors-smart:jar:1.1:runtime
[INFO] | | \- org.ow2.asm:asm:jar:5.0.3:runtime
[INFO] | +- junit:junit:jar:4.12:test
[INFO] | +- org.assertj:assertj-core:jar:2.6.0:test
[INFO] | +- org.mockito:mockito-core:jar:1.10.19:test
[INFO] | | \- org.objenesis:objenesis:jar:2.1:test
[INFO] | +- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] | +- org.hamcrest:hamcrest-library:jar:1.3:test
[INFO] | +- org.skyscreamer:jsonassert:jar:1.4.0:test
[INFO] | | \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
[INFO] | \- org.springframework:spring-test:jar:4.3.6.RELEASE:test
[INFO] +- org.springframework.boot:spring-boot-starter-data-jpa:jar:1.5.1.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-aop:jar:1.5.1.RELEASE:compile
[INFO] | | \- org.aspectj:aspectjweaver:jar:1.8.9:compile
[INFO] | +- org.hibernate:hibernate-core:jar:5.0.11.Final:compile
[INFO] | | +- org.jboss.logging:jboss-logging:jar:3.3.0.Final:compile
[INFO] | | +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile
[INFO] | | +- org.javassist:javassist:jar:3.21.0-GA:compile
[INFO] | | +- antlr:antlr:jar:2.7.7:compile
[INFO] | | +- org.jboss:jandex:jar:2.0.0.Final:compile
[INFO] | | +- dom4j:dom4j:jar:1.6.1:compile
[INFO] | | \- org.hibernate.common:hibernate-commons-annotations:jar:5.0.1.Final:compile
[INFO] | +- org.hibernate:hibernate-entitymanager:jar:5.0.11.Final:compile
[INFO] | +- javax.transaction:javax.transaction-api:jar:1.2:compile
[INFO] | +- org.springframework.data:spring-data-jpa:jar:1.11.0.RELEASE:compile
[INFO] | | +- org.springframework.data:spring-data-commons:jar:1.13.0.RELEASE:compile
[INFO] | | \- org.springframework:spring-orm:jar:4.3.6.RELEASE:compile
[INFO] | \- org.springframework:spring-aspects:jar:4.3.6.RELEASE:compile
[INFO] +- org.thymeleaf.extras:thymeleaf-extras-springsecurity4:jar:2.1.2.RELEASE:compile
[INFO] | +- org.thymeleaf:thymeleaf:jar:2.1.5.RELEASE:compile
[INFO] | | +- ognl:ognl:jar:3.0.8:compile
[INFO] | | \- org.unbescape:unbescape:jar:1.1.0.RELEASE:compile
[INFO] | \- org.slf4j:slf4j-api:jar:1.7.22:compile
[INFO] +- com.oracle:ojdbc6:jar:11.2.0.4:compile
[INFO] +- org.springframework.boot:spring-boot-starter-mail:jar:1.5.1.RELEASE:compile
[INFO] | +- org.springframework:spring-context:jar:4.3.6.RELEASE:compile
[INFO] | +- org.springframework:spring-context-support:jar:4.3.6.RELEASE:compile
[INFO] | \- com.sun.mail:javax.mail:jar:1.5.6:compile
[INFO] +- javax.mail:mail:jar:1.4.1:compile
[INFO] | \- javax.activation:activation:jar:1.1:compile
[INFO] +- org.scala-lang:scala-library:jar:2.10.0:compile
[INFO] +- cosine-lsh:cosinelsh:jar:1.0:compile
[INFO] \- com.fasterxml.jackson.core:jackson-databind:jar:2.4.4:compile
[INFO] +- com.fasterxml.jackson.core:jackson-annotations:jar:2.8.0:compile
[INFO] \- com.fasterxml.jackson.core:jackson-core:jar:2.8.6:compile
[INFO] \- com.fasterxml.jackson.core:jackson-core:jar:2.8.6:compile
和pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Blog</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>demo</name>
<description>Blog Project from the Software Technologies Course</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity4</artifactId>
<version>2.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.4</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
<!--<version>1.4.3.RELEASE</version>-->
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.1</version>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.10.0</version>
</dependency>
<dependency>
<groupId>cosine-lsh</groupId>
<artifactId>cosinelsh</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.4.4</version>
</dependency>
</dependencies>
<build>
<finalName>mlee-exe-jar</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<requiresUnpack>
<dependency>
<groupId>cosine-lsh</groupId>
<artifactId>cosinelsh</artifactId>
<version>1.0</version>
</dependency>
</requiresUnpack>
</configuration>
</plugin>
</plugins>
</build>
</project>
我被卡住了!有人可以帮忙吗?
提前致谢!
修改
我可以摆脱绑定日志,正如James Fry所建议的那样:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
但是,当jar文件通过命令窗口运行时,它会在几秒后开始和结束:
log4j:WARN No appenders could be found for logger (org.springframework.web.context.support.StandardServletEnvironment).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.1.RELEASE)
编辑2
org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:137) ~[spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:536) ~[spring-context-4.3.6.RELEASE.jar!/:4.3.6.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737) [spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370) [spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) [spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162) [spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151) [spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
at softuniBlog.DemoApplication.main(DemoApplication.java:12) [classes!/:0.0.1-SNAPSHOT]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_121]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_121]
at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_121]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [mlee-exe-jar.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [mlee-exe-jar.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [mlee-exe-jar.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) [mlee-exe-jar.jar:0.0.1-SNAPSHOT]
Caused by: org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:117) ~[spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.<init>(TomcatEmbeddedServletContainer.java:84) ~[spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:537) ~[spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:179) ~[spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:164) ~[spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:134) ~[spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
... 16 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Failed to initialize component [StandardServer[-1]]
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:112) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
at org.apache.catalina.startup.Tomcat.start(Tomcat.java:343) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:98) ~[spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
... 21 common frames omitted
Caused by: javax.xml.parsers.FactoryConfigurationError: Provider for class javax.xml.parsers.SAXParserFactory cannot be created
at javax.xml.parsers.FactoryFinder.findServiceProvider(Unknown Source) ~[na:1.8.0_121]
at javax.xml.parsers.FactoryFinder.find(Unknown Source) ~[na:1.8.0_121]
at javax.xml.parsers.SAXParserFactory.newInstance(Unknown Source) ~[na:1.8.0_121]
at org.apache.tomcat.util.digester.Digester.getFactory(Digester.java:432) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
at org.apache.tomcat.util.digester.Digester.getParser(Digester.java:617) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
at org.apache.tomcat.util.digester.Digester.getXMLReader(Digester.java:809) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1477) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
at org.apache.tomcat.util.modeler.modules.MbeansDescriptorsDigesterSource.execute(MbeansDescriptorsDigesterSource.java:170) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
at org.apache.tomcat.util.modeler.modules.MbeansDescriptorsDigesterSource.loadDescriptors(MbeansDescriptorsDigesterSource.java:149) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
at org.apache.tomcat.util.modeler.Registry.load(Registry.java:590) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
at org.apache.tomcat.util.modeler.Registry.loadDescriptors(Registry.java:669) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
at org.apache.tomcat.util.modeler.Registry.findDescriptor(Registry.java:703) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
at org.apache.tomcat.util.modeler.Registry.findManagedBean(Registry.java:479) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
at org.apache.tomcat.util.modeler.Registry.registerComponent(Registry.java:622) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
at org.apache.catalina.util.LifecycleMBeanBase.register(LifecycleMBeanBase.java:161) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
at org.apache.catalina.util.LifecycleMBeanBase.initInternal(LifecycleMBeanBase.java:61) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:829) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:107) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
... 24 common frames omitted
Caused by: java.lang.RuntimeException: Provider for class javax.xml.parsers.SAXParserFactory cannot be created
... 42 common frames omitted
Caused by: java.util.ServiceConfigurationError: javax.xml.parsers.SAXParserFactory: Error reading configuration file
at java.util.ServiceLoader.fail(Unknown Source) ~[na:1.8.0_121]
at java.util.ServiceLoader.parse(Unknown Source) ~[na:1.8.0_121]
at java.util.ServiceLoader.access$200(Unknown Source) ~[na:1.8.0_121]
at java.util.ServiceLoader$LazyIterator.hasNextService(Unknown Source) ~[na:1.8.0_121]
at java.util.ServiceLoader$LazyIterator.hasNext(Unknown Source) ~[na:1.8.0_121]
at java.util.ServiceLoader$1.hasNext(Unknown Source) ~[na:1.8.0_121]
at javax.xml.parsers.FactoryFinder$1.run(Unknown Source) ~[na:1.8.0_121]
at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_121]
... 42 common frames omitted
Caused by: java.io.FileNotFoundException: JAR entry META-INF/services/javax.xml.parsers.SAXParserFactory not found in C:\Users\n12017\AppData\Local\Temp\mlee-exe-jar.jar-spring-boot-libs-7a6ac511-970e-415f-bccb-432a1d0c7cee\cosinelsh-1.0.jar
at org.springframework.boot.loader.jar.JarURLConnection.throwFileNotFound(JarURLConnection.java:185) ~[mlee-exe-jar.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.jar.JarURLConnection.connect(JarURLConnection.java:104) ~[mlee-exe-jar.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.jar.JarURLConnection.getInputStream(JarURLConnection.java:169) ~[mlee-exe-jar.jar:0.0.1-SNAPSHOT]
at java.net.URL.openStream(Unknown Source) ~[na:1.8.0_121]
... 49 common frames omitted
答案 0 :(得分:0)
您应该从有问题的导入中排除其他实现 - 在这种情况下,您的cosinelsh jar包含SLF4J记录器绑定,以及通过Spring Boot引入的logback-classic-1.1.9.jar。 / p>
我认为正确的解决方法是构建没有这些依赖关系的cosinelsh jar,如果你能够(例如通过将范围设置为&#34;提供&#34;或类似)。如果无法做到这一点,您可以从spring-boot-starter-logging依赖项中删除spring boot提供的库(通过spring-boot-starter引入),例如:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>