英文:
What's the proper way to modify springboot app xml configuration?
问题
众所周知,Spring Boot 可以减轻开发人员使用复杂的 XML 配置的负担。我有一个 Spring Boot 应用程序。在进行了 Gradle 构建之后,我得到了一个 WAR 文件。如果我解压这个 WAR 文件,我会看到包含许多 XML 文件的 META-INF 和 WEB-INF 目录。
Spring Boot 所做的就是自动生成这些 XML 文件。那么我在这里的问题是,如何正确地更改这些 XML 文件中的设置呢?由于该应用程序是使用 Gradle 构建的,我可以将设置的更改放在 build.gradle 文件中,对吗?我在源代码树下找到了一些 XML 文件,我应该在那里进行更改吗?
举个例子,在我的 WAR 文件中有以下代码位于 ./WEB-INF/classes/META-INF/spring/appContext.xml
:
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd"
我计划在 xsi:schemaLocation
中添加或移除链接。做这个更改的正确方法是什么?
英文:
As we know, Springboot alleviates developer from complex XML configuration. I have an Springboot application. After gradle build, I get a WAR file. If I unpack the WAR, I see META-INF and WEB-INF directories that include bunch of XML files.
What Springboot does is to automatically generate those XML for you. Then my question here is what's the right way to change those settings in XMLs? Since the application is built using gradle, I assume I can put my changes of settings inside build.gradle, correct? I do find some XMLs under my source code tree, am I suppose to make change there?
For an example, I have these code in my WAR in ./WEB-INF/classes/META-INF/spring/appContext.xml
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd"
I plan to add/remove the urls in xsi:schemaLocation
. What's the right approach to do this?
专注分享java语言的经验与见解,让所有开发者获益!
评论