xml文件如何加载properties文件(spring容器加载properties文件)

发布时间:2026/7/19 5:57:54

xml文件如何加载properties文件(spring容器加载properties文件) 目的把jdbc.properties文件加载进applicationContext.xml文件当中resource文件目录下的applicationContext.xml文件?xml version1.0 encodingUTF-8? beans xmlnshttp://www.springframework.org/schema/beans xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance xsi:schemaLocationhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd !-- 在这里配置bean -- /beans以上为默认生成的内容。主命名空间为xmlnshttp://www.springframework.org/schema/beans操作?xml version1.0 encodingUTF-8? beans xmlnshttp://www.springframework.org/schema/beans xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance xmlns:contexthttp://www.springframework.org/schema/context xsi:schemaLocation http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd !-- 加载外部的properties文件-- context:property-placeholder locationclasspath:jdbc.properties/ !-- 在这里配置bean -- bean iddataSource classcom.mchange.v2.c3p0.ComboPooledDataSource property namedriverClass value${jdbc.driver}/property property namejdbcUrl value${jdbc.url}/property property nameuser value${jdbc.username}/property property namepassword value${jdbc.password}/property /bean /beans

相关新闻