启动Spring-boot时出错,我认为它缺少一些依赖

时间:2017-09-02 18:14:26

标签: java spring hibernate maven spring-mvc

> INFO 9346 --- [主要] b.c.checkin.checkin.CheckinApplication

  

:启动CheckinApplication v0.0.1-SNAPSHOT   带有PID 9346的MacBook-Air-de-Thomaz.local   (/Users/thomaz/Documents/Unitri/6Periodo/GestaoDaInovacao/checkin-api/target/checkin-0.0.1-SNAPSHOT.jar   由thomaz开始   /用户/托马斯/文档/ Unitri / 6Periodo / GestaoDaInovacao /签到-API)   2017-09-02 15:02:57.996 INFO 9346 --- [主要]   b.c.checkin.checkin.CheckinApplication:没有活动的配置文件集,   回到默认配置文件:默认2017-09-02 15:02:58.146   INFO 9346 --- [主要]   ationConfigEmbeddedWebApplicationContext:刷新   org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@41906a77:   启动日期[Sat Sep 02 15:02:58 BRT 2017];上下文层次结构的根   2017-09-02 15:02:58.284 INFO 9346 --- [pool-1-thread-1]   org.hibernate.validator.util.Version:Hibernate Validator   4.1.0.Final 2017-09-02 15:02:58.299 INFO 9346 --- [pool-1-thread-1] o.h.v.e.r.DefaultTraversableResolver:实例化一个实例   org.hibernate.validator.engine.resolver.JPATraversableResolver。   2017-09-02 15:02:59.748 WARN 9346 --- [主要]   ationConfigEmbeddedWebApplicationContext:遇到异常   在上下文初始化期间 - 取消刷新尝试:   org.springframework.beans.factory.BeanDefinitionStoreException:失败   处理配置类的导入候选   [br.com.checkin.checkin.CheckinApplication];嵌套异常是   java.lang.IllegalStateException:无法评估条件   org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration $ DispatcherServletConfiguration   由于   org / springframework / boot / context / embedded / ServletRegistrationBean没有   找到。确保您自己的配置不依赖于该类。   如果你是@ComponentScanning springframework,也会发生这种情况   包(例如,如果您将@ComponentScan放在默认包中)   错误)2017-09-02 15:02:59.755 INFO 9346 --- [主要]   utoConfigurationReportLoggingInitializer:

     

启动ApplicationContext时出错。显示自动配置   报告启用调试日志记录(以--debug开头)

     

2017-09-02 15:02:59.772 ERROR 9346 --- [主要]   o.s.boot.SpringApplication:应用程序启动失败

     

org.springframework.beans.factory.BeanDefinitionStoreException:失败   处理配置类的导入候选   [br.com.checkin.checkin.CheckinApplication];嵌套异常是   java.lang.IllegalStateException:无法评估条件   org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration $ DispatcherServletConfiguration   由于   org / springframework / boot / context / embedded / ServletRegistrationBean没有   找到。确保您自己的配置不依赖于该类。   如果你是@ComponentScanning springframework,也会发生这种情况   包(例如,如果您将@ComponentScan放在默认包中)   错误)   org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:616)   〜[spring-context-4.3.10.RELEASE.jar!/:4.3.10.RELEASE] at   org.springframework.context.annotation.ConfigurationClassParser.processDeferredImportSelectors(ConfigurationClassParser.java:548)   〜[spring-context-4.3.10.RELEASE.jar!/:4.3.10.RELEASE] at   org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:185)   〜[spring-context-4.3.10.RELEASE.jar!/:4.3.10.RELEASE] at   org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:308)   〜[spring-context-4.3.10.RELEASE.jar!/:4.3.10.RELEASE] at   org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:228)   〜[spring-context-4.3.10.RELEASE.jar!/:4.3.10.RELEASE] at   org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:270)   〜[spring-context-4.3.10.RELEASE.jar!/:4.3.10.RELEASE] at   org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:93)   〜[spring-context-4.3.10.RELEASE.jar!/:4.3.10.RELEASE] at   org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:687)   〜[spring-context-4.3.10.RELEASE.jar!/:4.3.10.RELEASE] at   org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:525)   〜[spring-context-4.3.10.RELEASE.jar!/:4.3.10.RELEASE] at   org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)   〜[spring-boot-1.5.6.RELEASE.jar!/:1.5.6.RELEASE] at   org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)   [spring-boot-1.5.6.RELEASE.jar!/:1.5.6.RELEASE] at   org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)   [spring-boot-1.5.6.RELEASE.jar!/:1.5.6.RELEASE] at   org.springframework.boot.SpringApplication.run(SpringApplication.java:303)   [spring-boot-1.5.6.RELEASE.jar!/:1.5.6.RELEASE] at   org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)   [spring-boot-1.5.6.RELEASE.jar!/:1.5.6.RELEASE] at   org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)   [spring-boot-1.5.6.RELEASE.jar!/:1.5.6.RELEASE] at   br.com.checkin.checkin.CheckinApplication.main(CheckinApplication.java:11)   [课程!/:0.0.1-SNAPSHOT] at   sun.reflect.NativeMethodAccessorImpl.invoke0(原生方法)   〜[na:1.8.0_111] at   sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)   〜[na:1.8.0_111] at   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)   〜[na:1.8.0_111] at java.lang.reflect.Method.invoke(Method.java:498)   〜[na:1.8.0_111] at   org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)   [checkin-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at   org.springframework.boot.loader.Launcher.launch(Launcher.java:87)   [checkin-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at   org.springframework.boot.loader.Launcher.launch(Launcher.java:50)   [checkin-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at   org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)   [checkin-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]引起:   java.lang.IllegalStateException:无法评估条件   org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration $ DispatcherServletConfiguration   由于   org / springframework / boot / context / embedded / ServletRegistrationBean没有   找到。确保您自己的配置不依赖于该类。   如果你是@ComponentScanning springframework,也会发生这种情况   包(例如,如果您将@ComponentScan放在默认包中)   错误)   org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:55)   〜[spring-boot-autoconfigure-1.3.1.RELEASE.jar!/:1.3.1.RELEASE] at   org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:102)   〜[spring-context-4.3.10.RELEASE.jar!/:4.3.10.RELEASE] at   org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:217)   〜[spring-context-4.3.10.RELEASE.jar!/:4.3.10.RELEASE] at   org.springframework.context.annotation.ConfigurationClassParser.processMemberClasses(ConfigurationClassParser.java:349)   〜[spring-context-4.3.10.RELEASE.jar!/:4.3.10.RELEASE] at   org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:264)   〜[spring-context-4.3.10.RELEASE.jar!/:4.3.10.RELEASE] at   org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:245)   〜[spring-context-4.3.10.RELEASE.jar!/:4.3.10.RELEASE] at   org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:606)   〜[spring-context-4.3.10.RELEASE.jar!/:4.3.10.RELEASE] ... 23常见   框架省略引起:java.lang.NoClassDefFoundError:   org / springframework / boot / context / embedded / ServletRegistrationBean at   org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration $ DefaultDispatcherServletCondition.checkServletRegistrations(DispatcherServletAutoConfiguration.java:166)   〜[spring-boot-autoconfigure-1.3.1.RELEASE.jar!/:1.3.1.RELEASE] at   org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration $ DefaultDispatcherServletCondition.getMatchOutcome(DispatcherServletAutoConfiguration.java:135)   〜[spring-boot-autoconfigure-1.3.1.RELEASE.jar!/:1.3.1.RELEASE] at   org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47)   〜[spring-boot-autoconfigure-1.3.1.RELEASE.jar!/:1.3.1.RELEASE] ... 29   常见帧省略引起:java.lang.ClassNotFoundException:   org.springframework.boot.context.embedded.ServletRegistrationBean at   java.net.URLClassLoader.findClass(URLClassLoader.java:381)   〜[na:1.8.0_111] at   java.lang.ClassLoader.loadClass(ClassLoader.java:424)〜[na:1.8.0_111]     在   org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:94)   〜[checkin-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at   java.lang.ClassLoader.loadClass(ClassLoader.java:357)~ [na:1.8.0_111]     ...省略了32个常见帧

的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>br.com.checkin</groupId>
    <artifactId>checkin</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>checkin</name>
    <description>checkin project for college's event.</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.6.RELEASE</version>
    </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-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.35</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>4.1.0.Final</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>4.3.10.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</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-autoconfigure</artifactId>
            <version>1.3.1.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>1.4.0.RELEASE</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

我不知道该怎么办。谢谢你的回答。我很抱歉英语,我来自巴西。

2 个答案:

答案 0 :(得分:2)

似乎您正在混合不同版本的spring-boot库以及Spring:

  • 对spring-boot-starter,spring-boot-autoconfigure和spring-boot-maven-plugin使用相同的版本1.5.6.RELEASE
  • 我不使用Spring启动,但我认为它带有自己的Spring版本,所以尝试删除对org.springframework的依赖:spring-context。
  • 运行mvn dependency:tree以确保所有版本的Spring和Spring Boot库都是一致的

答案 1 :(得分:0)

您可以像这样签出,例如,这是我的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>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.2.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.booksotre</groupId>
    <artifactId>bookstore</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>Bookstore</name>
    <description>frontend part</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>


        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</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-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.14</version>
        </dependency>

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

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>