0

I had been using springframework version 5.0.2.RELEASE so far. But recently, i switched to newer version 5.0.4.RELEASE. However, after this switch of JARs, @Configuration annotation is not recognized as predefined annotation in my project. Eclipse is asking me if i would like to create it. Is there any change in 5.0.4.REL version of springframework, which would stop recognizing the @Configuration annotation?

My 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>
    <groupId>com.drk.demo</groupId>
    <artifactId>springsecurity</artifactId>
    <packaging>war</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <name>springsecurity Maven Webapp</name>
    <url>http://maven.apache.org</url>
    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <springframework.version>5.0.4.RELEASE</springframework.version>
        <springsecurity.version>5.0.2.RELEASE</springsecurity.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
        <!-- Servlet, JSP and JSTL support -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
        </dependency>

        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>javax.servlet.jsp-api</artifactId>
            <version>2.3.1</version>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>

        <!-- Spring -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${springframework.version}</version>
        </dependency>

        <!-- Spring Security -->
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-web</artifactId>
            <version>${springsecurity.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
            <version>${springsecurity.version}</version>
        </dependency>
    </dependencies>
    <build>
        <finalName>springsecurity</finalName>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>3.2.0</version>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>

Error while using the @Configuration annotation : enter image description here

With mere change of modifying the springframework version in my POM file from 5.0.4.REL to 5.0.2.REL, my eclipse project starts to recognize the @Configuration annotation.

DevdattaK
  • 198
  • 9
  • (1) What is your version of Eclipse IDE? (2) Try to set `Build automatically` like [this link](http://help.eclipse.org/kepler/index.jsp?topic=%2Forg.eclipse.cdt.doc.user%2Ftasks%2Fcdt_t_autosave.htm) . (3) Let's me know the result! – Vy Do Feb 25 '18 at 01:55
  • (1) Eclipse ID Version : Version: Oxygen.1a Release (4.7.1a) Build id: 20171005-1200. I have STS installed on this eclipse for spring. (2) `Build automatically` is already enabled. (3) after confirming the 'build automatically' is enabled and using the version 5.0.2.REL, i am still getting the same error. – DevdattaK Feb 25 '18 at 02:10
  • Delete Eclipse IDE, download latest SpringTool Suite IDE, then import as Java Maven project. Your Eclipse IDE maybe corrupted. Nothing wrong with your source code. – Vy Do Feb 25 '18 at 02:12
  • If you are using maven or any other build tool, try to build from outside. and if its a success, for time being ignore this error. – Vipin CP Feb 25 '18 at 07:35
  • 1
    delete /clean your .m2 directory , and load maven file again for new spring version. – surya Feb 26 '18 at 03:59
  • @surya : thanks. This worked. However, after cleaning my local maven repository (.m2), i faced some other build issues, but found the solution for those [here](https://stackoverflow.com/questions/19661135/dynamic-web-module-3-0-3-1) – DevdattaK Mar 02 '18 at 02:08
  • great.. to know, just added the same as answer so that you can close this qn. – surya Mar 02 '18 at 02:12

1 Answers1

1

delete /clean your .m2 directory , and load maven file again for new spring version

surya
  • 2,581
  • 3
  • 22
  • 34