Intellij spring mvc支持问题

时间:2014-02-26 18:53:25

标签: spring intellij-idea

我使用的是IntelliJ Ultimate版本13,我对spring mvc控制器的支持存在问题。我的代码中有几个控制器。我会假设它们会被列出,显示在Spring工具按钮视图中。然后我可以看看他们的路径params等。我看到一些截图,它就像那样工作。我已经为我的项目添加了对Spring的支持,但是Intellij仍然看不到控制器。我做错了什么或有一些方法可以帮助Intellij正确检测控制器?我正在使用spring 4和java配置方法。 最好的祝福 编辑: 添加了示例控制器。

@Controller
public class HomeController extends AbstractBaseController {

    public static final String HOME_ID = "HOME";
    public static final String HOME_URL = "/";
    static Logger logger = LogManager.getLogger(HomeController.class);

    @Override
    protected void initializeRoutes() {
        routes.addRoute(HOME_ID, HOME_URL);
    }

    /**
     * Simply selects the home view to render by returning its name.
     */
    @RequestMapping(value = HOME_URL, method = RequestMethod.GET)
    public String home(Locale locale, Model model) {
        logger.warn("warn");
        Date date = new Date();
        DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);
        String formattedDate = dateFormat.format(date);
        model.addAttribute("serverTime", formattedDate);
        return "home";
    }
}

1 个答案:

答案 0 :(得分:-1)

为您的项目添加一些属性。

Project Structure->Facets->Click(+) and select spring facet from list and then point your module. 

但是如果你没有合适的方面,请安装额外的插件。

Settings->Ide settings->Plugins (browse repositories) and there you can search proper plugin.

这可能会有所帮助。