亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

基于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 關注
  • 118 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號