Spring Start throws an exception

I am trying to create the simplest application in spring and I have the following code for my only controller

    package User;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * Created by Bula on 14/02/14.
 */
@Controller
public class UsersController {

    @RequestMapping("/user")
    public String index()
    {
        return "user_index";
    }

}

Here is Main.java. One that loads everything:

  package main;

import javafx.application.Application;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;


@ComponentScan
@EnableAutoConfiguration
public class Main {

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

Also this is 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>blog</artifactId>
    <version>1.0-SNAPSHOT</version>
    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring</artifactId>
            <version>2.5.6</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>4.0.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-autoconfigure</artifactId>
            <version>1.0.0.BUILD-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot</artifactId>
            <version>1.0.0.BUILD-SNAPSHOT</version>
        </dependency>
    </dependencies>


</project>

I updated maven, so all libraries should be there. Here is the error that it throws (I tried to take a walk, but nothing appeared that came close to what I came across):

    Exception in thread "main" java.lang.NoSuchMethodError: org.springframework.core.annotation.AnnotationAwareOrderComparator.sort(Ljava/util/List;)V
    at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:371)
    at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:343)
    at org.springframework.boot.SpringApplication.initialize(SpringApplication.java:221)
    at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:197)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:877)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:866)
    at main.Main.main(Main.java:14)
    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 com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

Process finished with exit code 1

My user_index.html exists, but I do not think that the error in any form is related to it, since it has only an html tag. Here is an image with all the libraries that I have: enter image description here

+6
source share
2 answers

, maven Eclipse pom. , org.springframework.core.annotation.AnnotationAwareOrderComparator . 2.5.2 spring jar 4.0. 2.5.2 . . , .

, .

+7

(Virmundi) , "". maven

<!-- Provided Spring dependencies spring-beans, spring-context, spring-core, spring-tx -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>4.2.4.RELEASE</version>
    </dependency>

Spring,

java.lang.NoSuchMethodError: org.springframework.core.annotation.AnnotationAwareOrderComparator.sort(Ljava/util/List;)V
0

Source: https://habr.com/ru/post/1527012/


All Articles