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