zxf330301

applicationcontext.xml

 

在context中配置

如:在base-package指明一个包:

<context:component-scan base-package="cn.edu.dao"/>
表明cn.gacl.java包及其子包中,如果某个类的头上带有特定的注解

@Component,@Repository,@Service,@Controller,就会将这个对象作为Bean注册进Spring容器。

 

<!--解析Properties配置文件-->

<bean id="configProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="locations">
<list>
<value>classpath:/*.properties</value>
</list>
</property>
</bean>
<bean id="propertyConfigurer" class="com.shzq.common.config.GlobalConfig">
<property name="properties" ref="configProperties" />
</bean>
<!--数据库-->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${db.driver}" />
<property name="url" value="${db.url}" />
<property name="username" value="${db.username}" />
<property name="password" value="${db.password}" />
</bean>

分类:

技术点:

相关文章:

  • 2021-11-19
  • 2022-01-01
  • 2021-11-19
  • 2021-12-03
  • 2021-11-29
  • 2021-05-01
  • 2021-11-27
  • 2021-09-13
猜你喜欢
  • 2021-11-19
  • 2021-11-19
  • 2021-11-29
  • 2021-11-19
  • 2021-11-23
  • 2021-11-19
  • 2021-10-31
相关资源
相似解决方案