我正在使用IntelliJ Ultimate版本13,但我在支持Spring mvc控制器方面遇到了问题。我的代码中有几个控制器。我假设它们将被列出,显示在 Spring 工具按钮视图中。然后我可以看看他们的路径参数等。我看到一些屏幕截图,它就是这样工作的。我已经在我的项目中添加了对 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";
}
}
为您的项目添加一些属性。
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.
这可能会有所帮助。