简体   繁体   English

有关将Spring名称空间转换为XML配置文件的一些疑问。 究竟如何运作?

[英]Some doubts about Spring namespace into XML configuration file. How exactly works?

I am pretty new in Spring and I have a little doubt related the concept of namespace into my XML configuration files. 我在Spring刚接触新手,我有点怀疑将命名空间的概念与XML配置文件相关联。

So for example into the root-context.xml file of a project on which I am working on there is this definition: 因此,例如,在我正在处理的项目的root-context.xml文件中,就有以下定义:

<jee:jndi-lookup jndi-name="java:jboss/datasources/myDbDS" id="datasource" expected-type="javax.sql.DataSource" />

that have the jee namepace that is also specified into the beans external container by: 具有通过以下方式在bean外部容器中指定的jee namepace的代码:

xmlns:jee="http://www.springframework.org/schema/jee"

Now my doubt is, what exactly is this definition having id="datasource"? 现在,我的疑问是,这个具有id =“ datasource”的定义到底是什么? This one: 这个:

<jee:jndi-lookup jndi-name="java:jboss/datasources/myDbDS" id="datasource" expected-type="javax.sql.DataSource" />

Is it a classic bean of Spring having a specific namespace because it belong to a specific domain of bean (having a specific pourpose) or what? 它是Spring的经典bean,具有特定的名称空间,因为它属于bean的特定域(具有特定的目的)还是什么?

As Explained in the spring doc: 如春季文档中所述:

The jee tags deal with Java EE (Java Enterprise Edition)-related configuration issues, such as looking up a JNDI object and defining EJB references jee标记处理与Java EE(Java企业版)相关的配置问题,例如查找JNDI对象和定义EJB引用。

Here after an example from spring doc: 以下是spring doc中的示例:

Without using jee jndi-lookup 不使用jee jndi-lookup

<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="jdbc/MyDataSource"/>
</bean>

<bean id="userDao" class="com.foo.JdbcUserDao">
    <!-- Spring will do the cast automatically (as usual) -->
    <property name="dataSource" ref="dataSource"/>
</bean>

Using jee jndi-lookup 使用jee jndi-lookup

<jee:jndi-lookup id="dataSource" jndi-name="jdbc/MyDataSource"/>

<bean id="userDao" class="com.foo.JdbcUserDao">
    <!-- Spring will do the cast automatically (as usual) -->
    <property name="dataSource" ref="dataSource"/>
</bean>

More details here 在这里更多细节

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 关于XML构造函数注入Spring配置如何工作的一些疑问? - Some doubts about how exactly work the XML constructor injection Spring configuration? Spring MVC 主题支持究竟是如何工作的? (对提出的具体例子的一些疑问) - How exactly works the Spring MVC themes support? (some doubts about a proposed concrete example) 何先生在春季完全可以使用JPA? 一些疑问 - Ho exactly works JPA in Spring? Some doubts 关于Spring Application Context的Java配置(依赖注入)的一些疑问 - Some doubts about Java Configuration of the Spring Application Context (dependency injection) 关于如何在Spring应用程序中实现Hibernate DAO的一些疑问 - Some doubts about how implement Hibernate DAO in Spring applications 与Spring中的AOP配置有关的一些疑问 - Some doubts related to the AOP configuration in Spring 对Spring框架中JDBC逻辑的一些怀疑 - Some doubts about the logic of JDBC in Spring Framework 关于Spring MVC中的请求映射的一些疑问 - Some doubts about request mapping in Spring MVC 对春豆萌芽和破坏的一些怀疑 - Some doubts about Spring bean inizialitazion and destruction Spring Boot项目中的Spring Security配置如何工作? - How exactly works Spring Security configuration in this Spring Boot project?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM