java - 为什么 applicationContext.xml 中需要 <beans> 属性?

标签 java spring

我程序中使用的beans标签的属性是:

<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:p="http://www.springframework.org/schema/p"
   xmlns:aop="http://www.springframework.org/schema/aop"
   xmlns:tx="http://www.springframework.org/schema/tx"
   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
   http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
   http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">

每个属性指定的原因和内容是什么?

最佳答案

那些是 namespace 声明。理想情况下,xml 中的每个元素都必须绑定(bind)到特定的模式。如果您想使用 AOP、事务等多个 Spring 功能,则需要这些属性。

请阅读here用于 XML 架构和命名空间

关于java - 为什么 applicationContext.xml 中需要 <beans> 属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23423517/

相关文章:

java - 使用 EclEmma 的 Java 代码覆盖率不扫描预期的异常方法

java - Android ProgressDialog 位于另一个对话框中

java - 声纳 "Make transient or serializable"错误

spring - 在 Spring Security 中为不同的选项卡强制执行单独的 session

java - JInternalFrame 最小化,同时保持当前位置

java - 按主键查找与按唯一列查找有区别吗?

spring - 如何处理Spring WebClient获取应用程序/八位字节流作为主体输入流?

java - hibernate 的 JUnit : this instance does not yet exist as a row in the database

Spring 验证器用于数据库中的重复记录

java - 如何删除 ArrayList<ArrayList<String>> 的重复项并对数组进行排序