java中的接口是类吗
281
2023-01-01
浅谈xml配置spring profiles的几个注意点
先贴正确配置
xmlns:xsi="http://w3.org/2001/XMLSchema-instance" xmlns:aop="http://springframework.org/schema/aop" xmlns:task="http://springframework.org/schema/task" xmlns:context="http://springframework.org/schema/context" xsi:schemaLocation="http://springframework.org/schema/beans http://springframework.org/schema/beans/spring-beans.xsd http://springframework.org/schema/aop http://springframework.org/schema/aop/spring-aop.xsd http://springframework.org/schema/task http://springframework.org/schema/task/spring-task.xsd http://springframework.org/schema/context http://springframework.org/schema/context/spring-context.xsd"> <beans profile="dev">
xmlns:xsi="http://w3.org/2001/XMLSchema-instance"
xmlns:aop="http://springframework.org/schema/aop"
xmlns:task="http://springframework.org/schema/task"
xmlns:context="http://springframework.org/schema/context"
xsi:schemaLocation="http://springframework.org/schema/beans
http://springframework.org/schema/beans/spring-beans.xsd
http://springframework.org/schema/aop http://springframework.org/schema/aop/spring-aop.xsd
http://springframework.org/schema/task http://springframework.org/schema/task/spring-task.xsd
http://springframework.org/schema/context http://springframework.org/schema/context/spring-context.xsd">
<beans profile="dev">
一. xml标签的xsd版本
spring-beans.xsd 文件不要指定版本,也可以使用高版本(起码是3.1),原因是 spring profile 是3.1版本开始的。
...... xsi:schemaLocation="http://springframework.org/schema/beans http://springframework.org/schema/beans/spring-beans.xsd http://springframework.org/schema/aop http://springframework.org/schema/aop/spring-aop.xsd http://springframework.org/schema/task http://springframework.org/schema/task/spring-task.xsd http://springframework.org/schema/context http://springframework.org/schema/context/spring-context.xsd"> 二. dispatcherServlet文件配置 web.xml中配置了 DispatcherServlet 的 contextConfigLocation,需要在 spring-dispatch.xml 添加 spring profile 的配置,配置项同上。 classpath:config/spring/spHvjNkAJORring-context.xml classpath:config/spring/spring-security.xml ...... classpath:config/spring/spring-hessian-server.xml classpath:config/spring/spring-dispatch.xml classpath:config/spring/spring-security.xml
......
xsi:schemaLocation="http://springframework.org/schema/beans
http://springframework.org/schema/beans/spring-beans.xsd
http://springframework.org/schema/aop http://springframework.org/schema/aop/spring-aop.xsd
http://springframework.org/schema/task http://springframework.org/schema/task/spring-task.xsd
http://springframework.org/schema/context http://springframework.org/schema/context/spring-context.xsd">
二. dispatcherServlet文件配置
web.xml中配置了 DispatcherServlet 的 contextConfigLocation,需要在 spring-dispatch.xml 添加 spring profile 的配置,配置项同上。
classpath:config/spring/spHvjNkAJORring-context.xml
classpath:config/spring/spring-security.xml
......
classpath:config/spring/spring-hessian-server.xml
classpath:config/spring/spring-dispatch.xml
classpath:config/spring/spring-security.xml
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~