使用spring+mybatis写了一个jar程序,打包的时候将properties放在了jar包外面,现在applicationContext.xml可以读取到,但是读取不到数据库配置的properties文件
<context:property-placeholder location="classpath:db.properties"/> <context:component-scan base-package="com.test.service.impl"></context:component-scan> <bean class="org.springframework.jdbc.datasource.DriverManagerDataSource" id="dataSource"> <property name="driverClassName" value="${oracle.driverClassName}"></property> <property name="url" value="${oracle.url}"></property> <property name="username" value="${oracle.username}"></property> <property name="password" value="${oracle.password}"></property> </bean> <bean class="org.mybatis.spring.SqlSessionFactoryBean" id="factory"> <property name="dataSource" ref="dataSource"></property> </bean> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer" id="mapper"> <property name="basePackage" value="com.jl.batchregister.mapper"></property> <property name="sqlSessionFactoryBeanName" value="factory"></property> </bean> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource"></property> </bean>
如果将classpath改为classpath*之后可以读取到文件,但是${}占位符直接按字符串加载了,这种问题该怎么解决
蓝山帝景
达令说
相关分类