Why @JavaConfig not working in Spring MVC?

懵懂的女人 提交于 2019-11-28 11:51:14

Your project structure looks good but I doubt about the Eclipse configuration. Looks like your package is not being a part of Java Source.

Please execute the following steps:

1. Verify Source set for project. Go to project properties, Java Build Path and on Source tab, look for the entries src\main\java and src\main\resources. If not present, click on Add Folder to add source folders and it should similar to the below:

2. Go to Deployment Assembly and verify that the you have deployment entry mappings in the right way. If you do not find Deployment Assembly, go to Project Facets and go for the option to convert the project to faceted form. In Project Facets, you should have Dynamic Web Module selected.

Deployment Assembly should have mappings from Maven Dependencies to WEB-INF/lib, /src/main/webapp to /, src/main/resources to WEB-INF/classes and src/main/java to WEB-INF/classes. If any of these entries are missing, you may click Add and choose Folder or Libraries as required.

3. Make sure that you access the project using the Context Root name mentioned in the Web Project Settings of your project, if you are deploying the application through Eclipse and not through maven or some other tool.

In the above case, you can access the application by localhost:8080/UI where the server port 8080 may vary according to configuration.

Your code is all right. I was execute them without any changes on Tomcat 8 application server. Use Maven to package war, mvn clean package.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!