I am new with IntelliJ 14 and now I have migrated project from eclipse to intelliJ. My problem is that I'm getting this error:
java.io.FileNotFoundException: class path resource [src/main/java/com/myproject/beans/beans.xml] cannot be opened because it does not exist.
I am sure that beans.xml is in this directory.
AbstractApplicationContext context = new ClassPathXmlApplicationContext(
"com/myproject/beans/beans.xml");
context.close();
beans.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
......
</beans>
I'd strongly recommend moving your Spring XML into a src/main/resources
directory. This follows convention, then you can simply mark this new directory as a "resources root" by right-clicking it in the project view, and selecting "Mark Directory As..."
Sounds like IntelliJ is not putting your file (or that directory branch) onto the classpath. Try looking in File | Project Structure | Modules
File | Project Structure | Modules
File | Project Structure | Modules
.
Make sure the directory that holds com/myproject/beans/beans.xml
is listed on the far right as a Content Root
. If not, right-click on the directory and add it. Ideally it should be a Resource Folder
, separate from the src
folders.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.