Thanks, but that was not the solution. I understood why it does not work for me.
Since I made an announcement:
ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");
I thought that I would refer to the project root directory when there was a beans.xml file. Then I put the configuration file in src / main / resources and changed the initialization to:
ApplicationContext context = new ClassPathXmlApplicationContext("src/main/resources/beans.xml");
it was still an IO exception.
Then the file remained in src / main / resources /, but I changed the declaration to:
ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");
and he solved the problem - maybe it will be useful for someone.
Thanks and welcome!
Edit:
Since I get a lot of people to solve the problem, and I had my first experience working with a Spring student a few years ago, I feel like I want to briefly explain why it works.
When the project is compiled and packaged, all files and sub-folders from 'src / main / java' in the project go to the root directory of the packaged jar (the artifact we want to create). The same rule applies to 'src / main / resources'.
This convention is followed by many tools, such as maven or sbt, when creating a project (note: as the default configuration!). When the code (from the message) was in working mode, it could not find anything like "src / main / resources / beans.xml" due to the fact that beans.xml was in the root bank (copied to /beans.xml in the created can / ear / war).
When using ClassPa, thanksmlApplicationContext the correct location declaration for xml beans definitions in this case was "/beans.xml", since this is the path where it belongs in the jar and then the classpath.
This can be checked by unpacking the jar with the archiver (i.e. rar) and see its contents in the directory structure.
I would recommend reading classpath articles as optional.