Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/341.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无法配置Spring启动_Java_Spring_Maven_Slf4j - Fatal编程技术网

Java 无法配置Spring启动

Java 无法配置Spring启动,java,spring,maven,slf4j,Java,Spring,Maven,Slf4j,我试图用Spring Boot制作一个简单的“Hello World”应用程序。从中学习教程后,我发现以下错误: SLF4J: The requested version 1.7.16 by your slf4j binding is not compatible with [1.6] SLF4J: See http://www.slf4j.org/codes.html#version_mismatch for further details. 12:51:10.775 [main] DEBUG

我试图用Spring Boot制作一个简单的“Hello World”应用程序。从中学习教程后,我发现以下错误:

SLF4J: The requested version 1.7.16 by your slf4j binding is not compatible with [1.6]
SLF4J: See http://www.slf4j.org/codes.html#version_mismatch for further details.
12:51:10.775 [main] DEBUG org.springframework.boot.logging.ClasspathLoggingApplicationListener - Application failed to start with classpath: [file:/C:/Program%20Files/Java/jdk1.8.0_121/jre/lib/charsets.jar, file:/C:/Program%20Files/Java/jdk1.8.0_121/jre/lib/deploy.jar, file:/C:/Program%20Files/Java/jdk1.8.0_121/jre/lib/ext/access-bridge-64.jar, file:/C:/Program%20Files/Java/jdk1.8.0_121/jre/lib/ext/cldrdata.jar, file:/C:/Program%20Files/Java/jdk1.8.0_121/jre/lib/ext/dnsns.jar, file:/C:/Program%20Files/Java/jdk1.8.0_121/jre/lib/ext/jaccess.jar, file:/C:/Program%20Files/Java/jdk1.8.0_121/jre/lib/ext/jfxrt.jar, file:/C:/Program%20Files/Java/jdk1.8.0_121/jre/lib/ext/localedata.jar, file:/C:/Program%20Files/Java/jdk1.8.0_121/jre/lib/ext/nashorn.jar, file:/C:/Program%20Files/Java/jdk1.8.0_121/jre/lib/ext/sunec.jar, file:/C:/Program%20Files/Java/jdk1.8.0_121/jre/lib/ext/sunjce_provider.jar, file:/C:/Program%20Files/Java/jdk1.8.0_121/jre/lib/ext/sunmscapi.jar, file:/C:/Program%20Files/Java/jdk1.8.0_121/jre/lib/ext/sunpkcs11.jar, file:/C:/Program%20Files/Java/jdk1.8.0_121/jre/lib/ext/zipfs.jar, file:/C:/Program%20Files/Java/jdk1.8.0_121/jre/lib/javaws.jar, file:/C:/Program%20Files/Java/jdk1.8.0_121/jre/lib/jce.jar, file:/C:/Program%20Files/Java/jdk1.8.0_121/jre/lib/jfr.jar, file:/C:/Program%20Files/Java/jdk1.8.0_121/jre/lib/jfxswt.jar, file:/C:/Program%20Files/Java/jdk1.8.0_121/jre/lib/jsse.jar, file:/C:/Program%20Files/Java/jdk1.8.0_121/jre/lib/management-agent.jar, file:/C:/Program%20Files/Java/jdk1.8.0_121/jre/lib/plugin.jar, file:/C:/Program%20Files/Java/jdk1.8.0_121/jre/lib/resources.jar, file:/C:/Program%20Files/Java/jdk1.8.0_121/jre/lib/rt.jar, file:/C:/Users/nabil/IdeaProjects/TestSpringFramework/target/classes/, file:/C:/Users/nabil/.m2/repository/org/thymeleaf/thymeleaf/3.0.5.RELEASE/thymeleaf-3.0.5.RELEASE.jar, file:/C:/Users/nabil/.m2/repository/ognl/ognl/3.1.12/ognl-3.1.12.jar, file:/C:/Users/nabil/.m2/repository/org/javassist/javassist/3.20.0-GA/javassist-3.20.0-GA.jar, file:/C:/Users/nabil/.m2/repository/org/attoparser/attoparser/2.0.3.RELEASE/attoparser-2.0.3.RELEASE.jar, file:/C:/Users/nabil/.m2/repository/org/unbescape/unbescape/1.1.4.RELEASE/unbescape-1.1.4.RELEASE.jar, file:/C:/Users/nabil/.m2/repository/org/slf4j/slf4j-api/1.6.6/slf4j-api-1.6.6.jar, file:/C:/Users/nabil/.m2/repository/org/thymeleaf/extras/thymeleaf-extras-springsecurity4/3.0.2.RELEASE/thymeleaf-extras-springsecurity4-3.0.2.RELEASE.jar, file:/C:/Users/nabil/.m2/repository/org/springframework/security/spring-security-core/4.0.0.RELEASE/spring-security-core-4.0.0.RELEASE.jar, file:/C:/Users/nabil/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar, file:/C:/Users/nabil/.m2/repository/org/springframework/spring-aop/4.1.6.RELEASE/spring-aop-4.1.6.RELEASE.jar, file:/C:/Users/nabil/.m2/repository/org/springframework/spring-beans/4.1.6.RELEASE/spring-beans-4.1.6.RELEASE.jar, file:/C:/Users/nabil/.m2/repository/org/springframework/spring-core/4.1.6.RELEASE/spring-core-4.1.6.RELEASE.jar, file:/C:/Users/nabil/.m2/repository/org/springframework/spring-context/4.1.6.RELEASE/spring-context-4.1.6.RELEASE.jar, file:/C:/Users/nabil/.m2/repository/org/springframework/spring-expression/4.1.6.RELEASE/spring-expression-4.1.6.RELEASE.jar, file:/C:/Users/nabil/.m2/repository/org/springframework/security/spring-security-web/4.0.0.RELEASE/spring-security-web-4.0.0.RELEASE.jar, file:/C:/Users/nabil/.m2/repository/org/springframework/spring-web/4.1.6.RELEASE/spring-web-4.1.6.RELEASE.jar, file:/C:/Users/nabil/.m2/repository/org/springframework/security/spring-security-config/4.0.0.RELEASE/spring-security-config-4.0.0.RELEASE.jar, file:/C:/Users/nabil/.m2/repository/org/springframework/security/spring-security-acl/4.0.0.RELEASE/spring-security-acl-4.0.0.RELEASE.jar, file:/C:/Users/nabil/.m2/repository/org/springframework/spring-jdbc/4.1.6.RELEASE/spring-jdbc-4.1.6.RELEASE.jar, file:/C:/Users/nabil/.m2/repository/org/springframework/spring-tx/4.1.6.RELEASE/spring-tx-4.1.6.RELEASE.jar, file:/C:/Users/nabil/.m2/repository/org/springframework/boot/spring-boot-starter-web/1.5.2.RELEASE/spring-boot-starter-web-1.5.2.RELEASE.jar, file:/C:/Users/nabil/.m2/repository/org/springframework/boot/spring-boot-starter/1.5.2.RELEASE/spring-boot-starter-1.5.2.RELEASE.jar, file:/C:/Users/nabil/.m2/repository/org/springframework/boot/spring-boot/1.5.2.RELEASE/spring-boot-1.5.2.RELEASE.jar, file:/C:/Users/nabil/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/1.5.2.RELEASE/spring-boot-autoconfigure-1.5.2.RELEASE.jar, file:/C:/Users/nabil/.m2/repository/org/springframework/boot/spring-boot-starter-logging/1.5.2.RELEASE/spring-boot-starter-logging-1.5.2.RELEASE.jar, file:/C:/Users/nabil/.m2/repository/ch/qos/logback/logback-classic/1.1.11/logback-classic-1.1.11.jar, file:/C:/Users/nabil/.m2/repository/ch/qos/logback/logback-core/1.1.11/logback-core-1.1.11.jar, file:/C:/Users/nabil/.m2/repository/org/slf4j/slf4j-api/1.7.24/slf4j-api-1.7.24.jar, file:/C:/Users/nabil/.m2/repository/org/slf4j/jcl-over-slf4j/1.7.24/jcl-over-slf4j-1.7.24.jar, file:/C:/Users/nabil/.m2/repository/org/slf4j/jul-to-slf4j/1.7.24/jul-to-slf4j-1.7.24.jar, file:/C:/Users/nabil/.m2/repository/org/slf4j/log4j-over-slf4j/1.7.24/log4j-over-slf4j-1.7.24.jar, file:/C:/Users/nabil/.m2/repository/org/springframework/spring-core/4.3.7.RELEASE/spring-core-4.3.7.RELEASE.jar, file:/C:/Users/nabil/.m2/repository/org/yaml/snakeyaml/1.17/snakeyaml-1.17.jar, file:/C:/Users/nabil/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/1.5.2.RELEASE/spring-boot-starter-tomcat-1.5.2.RELEASE.jar, file:/C:/Users/nabil/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/8.5.11/tomcat-embed-core-8.5.11.jar, file:/C:/Users/nabil/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/8.5.11/tomcat-embed-el-8.5.11.jar, file:/C:/Users/nabil/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/8.5.11/tomcat-embed-websocket-8.5.11.jar, file:/C:/Users/nabil/.m2/repository/org/hibernate/hibernate-validator/5.3.4.Final/hibernate-validator-5.3.4.Final.jar, file:/C:/Users/nabil/.m2/repository/javax/validation/validation-api/1.1.0.Final/validation-api-1.1.0.Final.jar, file:/C:/Users/nabil/.m2/repository/org/jboss/logging/jboss-logging/3.3.0.Final/jboss-logging-3.3.0.Final.jar, file:/C:/Users/nabil/.m2/repository/com/fasterxml/classmate/1.3.3/classmate-1.3.3.jar, file:/C:/Users/nabil/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.8.7/jackson-databind-2.8.7.jar, file:/C:/Users/nabil/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.8.0/jackson-annotations-2.8.0.jar, file:/C:/Users/nabil/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.8.7/jackson-core-2.8.7.jar, file:/C:/Users/nabil/.m2/repository/org/springframework/spring-web/4.3.7.RELEASE/spring-web-4.3.7.RELEASE.jar, file:/C:/Users/nabil/.m2/repository/org/springframework/spring-aop/4.3.7.RELEASE/spring-aop-4.3.7.RELEASE.jar, file:/C:/Users/nabil/.m2/repository/org/springframework/spring-beans/4.3.7.RELEASE/spring-beans-4.3.7.RELEASE.jar, file:/C:/Users/nabil/.m2/repository/org/springframework/spring-context/4.3.7.RELEASE/spring-context-4.3.7.RELEASE.jar, file:/C:/Users/nabil/.m2/repository/org/springframework/spring-webmvc/4.3.7.RELEASE/spring-webmvc-4.3.7.RELEASE.jar, file:/C:/Users/nabil/.m2/repository/org/springframework/spring-expression/4.3.7.RELEASE/spring-expression-4.3.7.RELEASE.jar, file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%202017.1.1/lib/idea_rt.jar]
12:51:10.780 [main] ERROR org.springframework.boot.SpringApplication - Application startup failed
java.lang.IllegalAccessError: tried to access method org.springframework.core.convert.support.DefaultConversionService.addCollectionConverters(Lorg/springframework/core/convert/converter/ConverterRegistry;)V from class org.springframework.boot.bind.RelaxedConversionService
    at org.springframework.boot.bind.RelaxedConversionService.<init>(RelaxedConversionService.java:52)
    at org.springframework.boot.bind.RelaxedDataBinder.modifyProperties(RelaxedDataBinder.java:148)
    at org.springframework.boot.bind.RelaxedDataBinder.doBind(RelaxedDataBinder.java:128)
    at org.springframework.validation.DataBinder.bind(DataBinder.java:630)
    at org.springframework.boot.bind.PropertiesConfigurationFactory.doBindPropertiesToTarget(PropertiesConfigurationFactory.java:272)
    at org.springframework.boot.bind.PropertiesConfigurationFactory.bindPropertiesToTarget(PropertiesConfigurationFactory.java:240)
    at org.springframework.boot.context.config.ConfigFileApplicationListener.bindToSpringApplication(ConfigFileApplicationListener.java:235)
    at org.springframework.boot.context.config.ConfigFileApplicationListener.postProcessEnvironment(ConfigFileApplicationListener.java:186)
    at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEnvironmentPreparedEvent(ConfigFileApplicationListener.java:171)
    at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEvent(ConfigFileApplicationListener.java:157)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:151)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:128)
    at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:73)
    at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
    at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:336)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151)
    at SpringBootWebApplication.main(SpringBootWebApplication.java:14)
pom.xml:

<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <artifactId>BootExample</artifactId>
    <properties>
        <java.version>1.8</java.version>
    </properties>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.2.RELEASE</version>
    </parent>
    <dependencies>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>
</project>

4.0.0

但问题依然存在。有什么建议吗?

您是否尝试使用与Spring示例完全相同的代码?是的,完全相同;我用相同的代码尝试了教程中提到的
SampleController
类,但问题仍然存在。如果我是你,我宁愿遵循本教程,请添加maven资源树日志输出中的类路径与你发布的pom中得到的类路径非常不同。例如,类路径包含Thymeleaf 3、Spring安全性、旧的Spring Framework 4.1 JAR(Slring Boot 1.5需要4.3)等。您确定这是完整的pom,并且正确使用了它吗?
<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <artifactId>BootExample</artifactId>
    <properties>
        <java.version>1.8</java.version>
    </properties>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.2.RELEASE</version>
    </parent>
    <dependencies>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>
</project>
<exclusions>
    <exclusion>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
    </exclusion>
    <exclusion>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
    </exclusion>
</exclusions>