--I was using Spring MVC for war packaging and named the bean definition file application.xml.
--I wanted to run it with Spring Boot, so I first tried to read application.xml with
--Place application.xml directly under src / main / resources so that it is included in classpath
I get the following error:
java.lang.IllegalStateException: Failed to load property source from location 'classpath:/application.xml' ... stack trace ... Caused by: java.util.InvalidPropertiesFormatException: org.xml.sax.SAXParseException; lineNumber: 19; columnNumber: 87; Document root element "beans", must match DOCTYPE root "null". ... stack trace ...
Spring Boot's ConfigFileApplicationListener gives an error when trying to read xml as a configuration file (equivalent to application.properties) instead of a Bean definition file.
Since the default configuration file name is application and the extension supported by PropertiesPropertySourceLoader includes
xml, application.xml is the file name to be read. Also, since the default location in the configuration file includes directly under classpath,
classpath: /application.xml is read. As a result, it was a sad choice when I put application.xml directly under
src / main / resources, regardless of
--Rename the file
It's not good to use the name application.xml somehow in the first place.
If you make it according to the Spring Framework documentation, it will probably be ʻapplicationConfig.xml
, so ordinary people will not encounter it. --Java It may be a good time to convert this to @Configuration`.