为了账号安全,请及时绑定邮箱和手机立即绑定

基于spring配置文件导入bean资源

基于spring配置文件导入bean资源

守着星空守着你 2023-03-09 11:28:00
下面是我的 spring 项目中 servlet-context.xml 的代码。如果配置文件是 prod 和 demo-test.xml 如果配置文件是测试,我想导入 demo.xml 文件。<beans:beans xmlns="http://www.springframework.org/schema/mvc"             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"             xmlns:beans="http://www.springframework.org/schema/beans"             xmlns:task="http://www.springframework.org/schema/task"             xmlns:context="http://www.springframework.org/schema/context"             xsi:schemaLocation="                http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd                http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd                http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd                http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">    <!-- Enables the Spring MVC @Controller programming model -->    <annotation-driven />    <beans profile="test">        <import resource="demo-test.xml"></import>    </beans>    <beans profile="prod">        <import resource="demo.xml"></import>    </beans>    <task:annotation-driven            executor="defaultExecutor"/>    <!-- add an exception handler here. -->    <task:executor id="defaultExecutor"                   pool-size="50-200"                   queue-capacity="1200"                   keep-alive="10"                   rejection-policy="CALLER_RUNS"/></beans:beans>但我收到错误的The matching wildcard is strict, but no declaration can be found for element 'beans'.线路<beans profile="test">和'resource' attribute should be defined<import resource="demo-test.xml"></import>基于与 bean 配置文件相关的 spring xml 配置中的错误,我什至尝试将上下文更改为“ http://www.springframework.org/schema/beans/spring-beans-3.2.xsd ”,但没有成功。有人可以帮助我理解这个错误是什么意思,我该如何解决这个问题?
查看完整描述

1 回答

?
慕村225694

TA贡献1880条经验 获得超4个赞

xml文件<beans:beans xmlns="http://www.springframework.org/schema/mvc"顶部的 代替mvcbeans,这意味着默认命名空间mvc代替了beans。或者,限定 bean 标记:使用<beans:beans profile="test">...instead of<beans profile="test">...<beans:import resource...instead of <import resource...,或者将默认命名空间更改为beans按原样使用 xml



查看完整回答
反对 回复 2023-03-09
  • 1 回答
  • 0 关注
  • 67 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信