尝试运行 spring boot 应用程序时没有这样的方法错误 [英] no such method error when trying to run spring boot app

查看:48
本文介绍了尝试运行 spring boot 应用程序时没有这样的方法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Spring Boot 应用程序这是我收到的错误:

I have a spring boot app Here is the error i am getting :

java.lang.NoSuchMethodError: org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider: method <init>()V not found
at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.<init>(ClassPathBeanDefinitionScanner.java:158)
at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.<init>(ClassPathBeanDefinitionScanner.java:138)
at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.<init>(ClassPathBeanDefinitionScanner.java:111)
at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.<init>(ClassPathBeanDefinitionScanner.java:83)
at org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext.<init>(AnnotationConfigEmbeddedWebApplicationContext.java:67)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at java.lang.Class.newInstance(Class.java:374)
at org.springframework.beans.BeanUtils.instantiate(BeanUtils.java:77)
at org.springframework.boot.SpringApplication.createApplicationContext(SpringApplication.java:529)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:299)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
at com.ceb.tc.TcCacheApplication.main(TcCacheApplication.java:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
2017-08-17 07:49:35,202 [background-preinit] INFO  org.hibernate.validator.internal.util.Version - HV000001: Hibernate Validator 5.3.5.Final

我尝试将 spring boot 应用程序版本更改为 1.5.1 到 1.5.6,但没有用.我现在卡住了.所以需要帮助

I have tried changing the spring boot app version to 1.5.1 to 1.5.6 but it is of no use. I am stuck now. So need help

这是我的 pom.xml

Here is my pom.xml

    <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.0.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.7</java.version>
</properties>

<repositories>
    <repository>
        <id>admin-repository</id>
        <name>adminRepo</name>
        <url>file:${project.build.directory}\..\..\admin\mvnrepository</url>
        <releases>
            <enabled>true</enabled>
            <updatePolicy>always</updatePolicy>
            <checksumPolicy>ignore</checksumPolicy>
        </releases>
        <snapshots>
            <enabled>true</enabled>
            <updatePolicy>always</updatePolicy>
            <checksumPolicy>ignore</checksumPolicy>
        </snapshots>
    </repository>
</repositories>


<dependencies>


    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-logging</artifactId>
            </exclusion>
            <exclusion>
                <artifactId>hibernate-core</artifactId>
                <groupId>org.hibernate</groupId>
            </exclusion>
            <exclusion>
                <artifactId>hibernate-entitymanager</artifactId>
                <groupId>org.hibernate</groupId>
            </exclusion>
            <exclusion>
                <groupId>org.springframework.data</groupId>
                <artifactId>spring-data-jpa</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-redis</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <exclusions>
            <exclusion>
                <artifactId>hibernate-validator</artifactId>
                <groupId>org.hibernate</groupId>
            </exclusion>
        </exclusions>
    </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-devtools</artifactId>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-log4j</artifactId>
        <version>1.3.8.RELEASE</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/net.sourceforge.jtds/jtds -->
    <dependency>
        <groupId>net.sourceforge.jtds</groupId>
        <artifactId>jtds</artifactId>
        <version>1.3.1</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/commons-lang/commons-lang -->
    <dependency>
        <groupId>commons-lang</groupId>
        <artifactId>commons-lang</artifactId>
        <version>2.6</version>
    </dependency>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>3.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi</artifactId>
        <version>3.6</version>
    </dependency>


    <dependency>
        <groupId>org.apache.solr</groupId>
        <artifactId>solr-solrj</artifactId>
        <version>3.6.1</version>
    </dependency>

    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.3.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpcore</artifactId>
        <version>4.3</version>
    </dependency>
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpmime</artifactId>
        <version>4.3.1</version>
    </dependency>


    <dependency>
        <groupId>net.sf.flexjson</groupId>
        <artifactId>flexjson</artifactId>
        <version>2.1</version>
    </dependency>


    <dependency>
        <groupId>axis</groupId>
        <artifactId>axis</artifactId>
        <version>1.2</version>
    </dependency>

    <dependency>
        <groupId>javax.xml</groupId>
        <artifactId>jaxrpc-api</artifactId>
        <version>1.1</version>
    </dependency>

    <dependency>
        <groupId>jdom</groupId>
        <artifactId>jdom</artifactId>
        <version>b7</version>
    </dependency>

    <dependency>
        <groupId>javax.mail</groupId>
        <artifactId>mail</artifactId>
        <version>1.4.5</version>
    </dependency>

    <dependency>
        <groupId>javax.activation</groupId>
        <artifactId>activation</artifactId>
        <version>1.1.1</version>
    </dependency>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>4.2.2.Final</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>4.2.2.Final</version>
        <exclusions>
            <exclusion>
                <groupId>cglib</groupId>
                <artifactId>cglib</artifactId>
            </exclusion>
            <exclusion>
                <groupId>dom4j</groupId>
                <artifactId>dom4j</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-core</artifactId>
        <version>3.2.5.RELEASE</version>
        <scope>compile</scope>
        <exclusions>
            <exclusion>
                <artifactId>commons-logging</artifactId>
                <groupId>commons-logging</groupId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-config</artifactId>
        <version>3.2.5.RELEASE</version>
        <scope>compile</scope>
        <exclusions>
            <exclusion>
                <artifactId>commons-logging</artifactId>
                <groupId>commons-logging</groupId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
        <!--  --><version>5.3.5.Final</version>
    </dependency>

    <dependency>
        <groupId>javax.validation</groupId>
        <artifactId>validation-api</artifactId>
        <version>1.0.0.GA</version>
    </dependency>
    </dependencies>

这是运行应用程序的类

import java.util.TimeZone;

import javax.annotation.PostConstruct;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class TcCacheApplication {

    @PostConstruct
    void started() {
        TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
    }

    public static void main(String[] args) {
        SpringApplication.run(TcCacheApplication.class, args);
    }
}

更新

我已经更正了我的 pom.xml 以适应建议的更改,除了 log4j 版本大多数已被删除.我无法删除 log4j 的版本,因为它给了我一个错误,即在命令mvn clean install"时需要版本号

I have corrected my pom.xml to accommodate the changes suggested, except for the log4j version most have been removed . I can't remove the version for log4j because it gives me an error that version number is required at the time of command "mvn clean install"

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
                <exclusion>
                    <artifactId>hibernate-core</artifactId>
                    <groupId>org.hibernate</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>hibernate-entitymanager</artifactId>
                    <groupId>org.hibernate</groupId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework.data</groupId>
                    <artifactId>spring-data-jpa</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <artifactId>hibernate-validator</artifactId>
                    <groupId>org.hibernate</groupId>
                </exclusion>
            </exclusions>
        </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-devtools</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-log4j</artifactId>
             <version>1.3.8.RELEASE</version> 
        </dependency>

        <!-- https://mvnrepository.com/artifact/net.sourceforge.jtds/jtds -->
        <dependency>
            <groupId>net.sourceforge.jtds</groupId>
            <artifactId>jtds</artifactId>
            <version>1.3.1</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/commons-lang/commons-lang -->
        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.6</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>3.6</version>
        </dependency>


        <dependency>
            <groupId>org.apache.solr</groupId>
            <artifactId>solr-solrj</artifactId>
            <version>3.6.1</version>
        </dependency>

        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpcore</artifactId>
            </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpmime</artifactId>
            </dependency>


        <dependency>
            <groupId>net.sf.flexjson</groupId>
            <artifactId>flexjson</artifactId>
            <version>2.1</version>
        </dependency>


        <dependency>
            <groupId>axis</groupId>
            <artifactId>axis</artifactId>
            <version>1.2</version>
        </dependency>

        <dependency>
            <groupId>javax.xml</groupId>
            <artifactId>jaxrpc-api</artifactId>
            <version>1.1</version>
        </dependency>

        <dependency>
            <groupId>jdom</groupId>
            <artifactId>jdom</artifactId>
            <version>b7</version>
        </dependency>

        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>mail</artifactId>
            <version>1.4.5</version>
        </dependency>

        <dependency>
            <groupId>javax.activation</groupId>
            <artifactId>activation</artifactId>
            <version>1.1.1</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>cglib</groupId>
                    <artifactId>cglib</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>dom4j</groupId>
                    <artifactId>dom4j</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-core</artifactId>
            <scope>compile</scope>
            <exclusions>
                <exclusion>
                    <artifactId>commons-logging</artifactId>
                    <groupId>commons-logging</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>

            <scope>compile</scope>
            <exclusions>
                <exclusion>
                    <artifactId>commons-logging</artifactId>
                    <groupId>commons-logging</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            </dependency>

        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            </dependency>
        <!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
</dependency>   

+- com.gartner.ceb:admin:jar:12.0.0:compile
+- org.springframework.boot:spring-boot-starter-data-jpa:jar:1.5.5.RELEASE:compile
|  +- org.springframework.boot:spring-boot-starter:jar:1.5.5.RELEASE:compile
|  |  \- org.yaml:snakeyaml:jar:1.17:runtime

|  +- org.springframework.boot:spring-boot-starter-aop:jar:1.5.5.RELEASE:compile
|  |  \- org.aspectj:aspectjweaver:jar:1.8.10:compile
|  +- org.springframework.boot:spring-boot-starter-jdbc:jar:1.5.5.RELEASE:compile
|  |  +- org.apache.tomcat:tomcat-jdbc:jar:8.5.16:compile
|  |  |  \- org.apache.tomcat:tomcat-juli:jar:8.5.16:compile
|  |  \- org.springframework:spring-jdbc:jar:4.3.10.RELEASE:compile
|  +- javax.transaction:javax.transaction-api:jar:1.2:compile
|  \- org.springframework:spring-aspects:jar:4.3.10.RELEASE:compile
+- org.springframework.boot:spring-boot-starter-data-redis:jar:1.5.5.RELEASE:compil
|  +- org.springframework.data:spring-data-redis:jar:1.8.5.RELEASE:compile
|  |  +- org.springframework.data:spring-data-keyvalue:jar:1.2.5.RELEASE:compile
|  |  +- org.springframework:spring-oxm:jar:4.3.10.RELEASE:compile
|  |  \- org.springframework:spring-context-support:jar:4.3.10.RELEASE:compile
|  \- redis.clients:jedis:jar:2.9.0:compile
|     \- org.apache.commons:commons-pool2:jar:2.4.2:compile
+- org.springframework.boot:spring-boot-starter-web:jar:1.5.5.RELEASE:compile
|  +- org.springframework.boot:spring-boot-starter-tomcat:jar:1.5.5.RELEASE:compile
|  |  +- org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.16:compile
|  |  +- org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.16:compile
|  |  \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.5.16:compile
|  +- com.fasterxml.jackson.core:jackson-databind:jar:2.8.9:compile
|  |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.8.0:compile
|  |  \- com.fasterxml.jackson.core:jackson-core:jar:2.8.9:compile
|  +- org.springframework:spring-web:jar:4.3.10.RELEASE:compile
|  \- org.springframework:spring-webmvc:jar:4.3.10.RELEASE:compile
+- org.springframework.boot:spring-boot-starter-test:jar:1.5.5.RELEASE:test
|  +- org.springframework.boot:spring-boot-test:jar:1.5.5.RELEASE:test
|  +- org.springframework.boot:spring-boot-test-autoconfigure:jar:1.5.5.RELEASE:tes
|  +- com.jayway.jsonpath:json-path:jar:2.2.0:test
|  |  \- net.minidev:json-smart:jar:2.2.1:test
|  |     \- net.minidev:accessors-smart:jar:1.1:test
|  |        \- org.ow2.asm:asm:jar:5.0.3:test
|  +- junit:junit:jar:4.12:test
|  +- org.assertj:assertj-core:jar:2.6.0:test
|  +- org.mockito:mockito-core:jar:1.10.19:test
|  |  \- org.objenesis:objenesis:jar:2.1:test
|  +- org.hamcrest:hamcrest-core:jar:1.3:test
|  +- org.hamcrest:hamcrest-library:jar:1.3:test
|  +- org.skyscreamer:jsonassert:jar:1.4.0:test
|  |  \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
|  +- org.springframework:spring-core:jar:4.3.10.RELEASE:compile
|  \- org.springframework:spring-test:jar:4.3.10.RELEASE:test
+- org.springframework.boot:spring-boot-devtools:jar:1.5.5.RELEASE:compile
|  +- org.springframework.boot:spring-boot:jar:1.5.5.RELEASE:compile
|  \- org.springframework.boot:spring-boot-autoconfigure:jar:1.5.5.RELEASE:compile
+- org.springframework.boot:spring-boot-starter-log4j:jar:1.3.8.RELEASE:compile
|  +- org.slf4j:jcl-over-slf4j:jar:1.7.25:compile
|  +- org.slf4j:jul-to-slf4j:jar:1.7.25:compile
|  +- org.slf4j:slf4j-log4j12:jar:1.7.25:compile
|  \- log4j:log4j:jar:1.2.17:compile
+- net.sourceforge.jtds:jtds:jar:1.3.1:compile
+- commons-lang:commons-lang:jar:2.6:compile
+- org.apache.commons:commons-lang3:jar:3.1:compile
+- org.apache.poi:poi:jar:3.6:compile
|  \- commons-logging:commons-logging:jar:1.1:compile
|     +- logkit:logkit:jar:1.0.1:compile
|     +- avalon-framework:avalon-framework:jar:4.1.3:compile
|     \- javax.servlet:servlet-api:jar:2.3:compile
+- org.apache.solr:solr-solrj:jar:3.6.1:compile
|  +- commons-httpclient:commons-httpclient:jar:3.1:compile
|  +- commons-io:commons-io:jar:2.1:compile
|  +- org.codehaus.woodstox:wstx-asl:jar:3.2.7:runtime
|  \- org.slf4j:slf4j-api:jar:1.7.25:compile
+- org.apache.httpcomponents:httpclient:jar:4.5.3:compile
|  \- commons-codec:commons-codec:jar:1.10:compile
+- org.apache.httpcomponents:httpcore:jar:4.4.6:compile
+- org.apache.httpcomponents:httpmime:jar:4.5.3:compile
+- net.sf.flexjson:flexjson:jar:2.1:compile
+- axis:axis:jar:1.2:compile
+- javax.xml:jaxrpc-api:jar:1.1:compile
+- jdom:jdom:jar:b7:compile
+- javax.mail:mail:jar:1.4.5:compile
+- javax.activation:activation:jar:1.1.1:compile
+- org.hibernate:hibernate-core:jar:5.0.12.Final:compile
|  +- org.jboss.logging:jboss-logging:jar:3.3.1.Final:compile
|  +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile
|  +- org.javassist:javassist:jar:3.21.0-GA:compile
|  +- antlr:antlr:jar:2.7.7:compile
|  +- org.apache.geronimo.specs:geronimo-jta_1.1_spec:jar:1.1.1:compile
|  +- org.jboss:jandex:jar:2.0.0.Final:compile
|  +- dom4j:dom4j:jar:1.6.1:compile
|  \- org.hibernate.common:hibernate-commons-annotations:jar:5.0.1.Final:compile
+- org.hibernate:hibernate-entitymanager:jar:5.0.12.Final:compile
+- org.springframework.security:spring-security-core:jar:4.2.3.RELEASE:compile
|  +- aopalliance:aopalliance:jar:1.0:compile
|  +- org.springframework:spring-aop:jar:4.3.10.RELEASE:compile
|  +- org.springframework:spring-beans:jar:4.3.10.RELEASE:compile
|  \- org.springframework:spring-expression:jar:4.3.10.RELEASE:compile
+- org.springframework.security:spring-security-config:jar:4.2.3.RELEASE:compile
+- org.springframework.data:spring-data-jpa:jar:1.11.5.RELEASE:compile
|  +- org.springframework.data:spring-data-commons:jar:1.13.5.RELEASE:compile
|  +- org.springframework:spring-orm:jar:4.3.10.RELEASE:compile
|  +- org.springframework:spring-tx:jar:4.3.10.RELEASE:compile
|  \- org.aspectj:aspectjrt:jar:1.8.10:compile
+- org.hibernate:hibernate-validator:jar:5.3.5.Final:compile
|  \- com.fasterxml:classmate:jar:1.3.3:compile
+- javax.validation:validation-api:jar:1.1.0.Final:compile
\- org.springframework:spring-context:jar:4.3.10.RELEASE:compile
------------------------------------------------------------------------
BUILD SUCCESS

推荐答案

基本上你的依赖是一团糟.

Basically your dependencies are a mess.

  1. 您正在混合 Spring Boot 1.5.0 和 1.3.8 发布 jar,切勿混合框架的版本
  2. 您正在包含一个旧版本的 Spring Security,其中包含一个旧的、不受支持的 Spring 版本
  3. 如果您想使用特定版本的 Hibernate,只需指定版本即可,不要自己包含它们.

您的依赖项应如下所示.

Your dependencies should look something like this.

<dependencies>
  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-jpa</artifactId>
    <exclusions>
      <exclusion>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-logging</artifactId>
      </exclusion>      
    </exclusions>
  </dependency>
  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-redis</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-security</artifactId>
  </dependency>
  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-mail</artifactId>
  </dependency>
  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-validation</artifactId>
  </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-devtools</artifactId>
    <optional>true</optional>
  </dependency>
  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-log4j</artifactId>
  </dependency>
  <!-- https://mvnrepository.com/artifact/net.sourceforge.jtds/jtds -->
  <dependency>
    <groupId>net.sourceforge.jtds</groupId>
    <artifactId>jtds</artifactId>
    <version>1.3.1</version>
  </dependency>
  <!-- https://mvnrepository.com/artifact/commons-lang/commons-lang -->
  <dependency>
    <groupId>commons-lang</groupId>
    <artifactId>commons-lang</artifactId>
    <version>2.6</version>
  </dependency>
  <dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-lang3</artifactId>
    <version>3.1</version>
  </dependency>
  <dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi</artifactId>
    <version>3.6</version>
  </dependency>
  <dependency>
    <groupId>org.apache.solr</groupId>
    <artifactId>solr-solrj</artifactId>
    <version>3.6.1</version>
  </dependency>
  <dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpclient</artifactId>
    <version>4.3.1</version>
  </dependency>
  <dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpcore</artifactId>
    <version>4.3</version>
  </dependency>
  <dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpmime</artifactId>
    <version>4.3.1</version>
  </dependency>
  <dependency>
    <groupId>net.sf.flexjson</groupId>
    <artifactId>flexjson</artifactId>
    <version>2.1</version>
  </dependency>
  <dependency>
    <groupId>axis</groupId>
    <artifactId>axis</artifactId>
    <version>1.2</version>
  </dependency>
  <dependency>
    <groupId>javax.xml</groupId>
    <artifactId>jaxrpc-api</artifactId>
    <version>1.1</version>
  </dependency>
  <dependency>
    <groupId>jdom</groupId>
    <artifactId>jdom</artifactId>
    <version>b7</version>
  </dependency>
</dependencies>

注意添加了 spring-boot-starter-securityspring-boot-starter-validationspring-boot-starter-mailcode> 以获得正确的依赖项.

Notice the addition of the spring-boot-starter-security, spring-boot-starter-validation and spring-boot-starter-mail to get the proper dependencies.

要固定休眠版本,请添加此

To pin the hibernate version add this

<properties>
 <hibernate.version>4.2.2.Final</hibernate.version>
</properties>

这篇关于尝试运行 spring boot 应用程序时没有这样的方法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆