Setting up spring app with spring data repositories and mongo db

前端 未结 5 890
孤街浪徒
孤街浪徒 2021-01-06 04:09

I am facing an issue when defining mongo repository in application-context.xml

Following is the error i get in xml

Error occured process

相关标签:
5条回答
  • 2021-01-06 04:32

    Make sure you don't accidentally pull in an older Spring version (something before 3.2.5) into the classpath. The older methods don't have the method listed in the exception public. This is then causing the exception. I recommend to use the following Maven config snippet to enforce all Spring libraries to be in 4.0.2:

    <dependencyManagement>
      <dependencies>
        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-framework-bom</artifactId>
          <version>4.0.2.RELEASE</version>
          <type>pom</type>
          <scope>import</scope>
        </dependency>
      </dependencies>
    </dependencyManagement>
    
    0 讨论(0)
  • 2021-01-06 04:36

    In my case it was spring data jpa version which was causing problem. I am not using spring data mongodb but spring data jpa instead. I started this projected today with latest versions (spring-framework 4.0.2.RELEASE, spring-data-jpa 1.5.0.RELEASE). I ensured that all transitive dependencies from maven (from spring side as well as from spring data side) are that of latest version but no lock.

    Following this thread, tried to downgrade spring version to 4.0.0.RELEASE but no luck. I even explored the org.springframework.context.annotation.AnnotationConfigUtils class from spring-context-4.0.2.RELEASE.jar (and also in spring-context-4.0.0.RELEASE.jar) from within my workspace and confirmed that indeed processCommonDefinitionAnnotations is a public method thus IllegalAccessError can not be an issue resulting from these jars.

    Finally I downgraded my spring-data-jpa from 1.5.0.RELEASE to 1.4.4.RELEASE and voila all problems are solved on maven update. I am using STS 3.4 if it helps anyone.

    Since this was the first post I found on googling this error, thought of posting it here so that others who are facing same problems can potentially solve it with this tip. I have opened bug report at https://jira.springsource.org/browse/DATAJPA-490

    @Oliver, tried the dependency management suggested but no luck. I have also added dependency:list output to the bug report as requested.

    0 讨论(0)
  • 2021-01-06 04:40

    The real solution is to upgrade your eclipse/STS spring plugin to the latest.

    This is mentioned in https://jira.springsource.org/browse/DATAJPA-490, but not that clearly.

    0 讨论(0)
  • 2021-01-06 04:56

    Finally I changed the spring jar version to 4.0.0 and then removed all spring jars from the maven repository and tried to (updated maven first)build again..It worked. I am pretty sure that it will work with 4.0.1 spring jars also.( I was having another project with the same configuration and it was working fine with 4.0.1 jars:)) I contribute this issue to maven and eclipse. Some issue that I don't have any clue at all.

    0 讨论(0)
  • 2021-01-06 04:56

    I ran into the same issue. After spending several hours fighting with the problem @Avnish's answer pointed me in the right direction. More specifically, the issue he opened at https://jira.springsource.org/browse/DATAJPA-490 really cleared things up.

    Spring-Data-JPA 1.5.1.BUILD-SNAPSHOT or 1.6.0.BUILD-SNAPSHOT has a guard that indicates exactly which jar is causing the problem.

    In my case, I was using Eclipse Juno (4.2) with Spring IDE 3.4.0 which was causing the problem. I had to upgrade to Spring IDE 3.5.0 to make the issue go away. I had to use the http://dist.springsource.com/snapshot/TOOLS/nightly/e4.2 update site to update Juno to Spring IDE 3.5.0.

    It also appears that STS 3.5.0RC1 and beyond get this working as well.

    0 讨论(0)
提交回复
热议问题