Spring Import Error Contextual Annotation

When I import the Controller annotation into Spring, the following error appears:

The import org.springframework.stereotype.Controller conflicts with a type defined in the same file 

Here is the (very simple) code of my web-MVC startup project:

 package com.company.project.servlet; import org.springframework.stereotype.Controller; @Controller public class Controller { public String execute(){ System.out.println("Controller executing..."); return("page"); } } 

As you can see, there is no reason for the error to be shown here. Do you have any ideas on what is going to happen? Thanks!

Useful information: - Eclipse Spring Tool Suite 3.3.0 (above Kepler) - Eclipse jars version 4.0.0.M1 (These should be the best versions of all this)

+4
source share
2 answers

The message says it all:

Import org.springframework.stereotype.Controller conflicts with type defined in same file

One type is specified in the file: class Controller , which conflicts with the Controller annotation.

 @Controller ---> same name ^ | public class Controller { 

Choose a different name or use the full enumeration name:

 @org.springframework.stereotype.Controller public class Controller { 
+18
source

@Controller is a keyword, so choose a different class name.

0
source

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


All Articles