<bean id="sqlsessionfactory" class="org.mybatis.spring.sqlsessionfactorybean">
<property name="datasource" ref="datasource" />
<property name="configlocation" value="classpath:sqlmapconfig.xml"></property>
<property name="mapperlocations" value="classpath*:mapper/**/*mapper.xml"></property>
</bean>
<context:property-placeholder location="classpath:/jdbc.properties" />
1.无论是classpath还是classpath*都可以加载整个classpath下(包括jar包里面)的资源文件。
2.classpath只会返回第一个匹配的资源,查找路径是优先在项目中存在资源文件,再查找jar包。
3.文件名字包含通配符资源(如果spring-*.xml,spring*.xml), 如果根目录为"", classpath加载不到任何资源, 而classpath*则可以加载到classpath中可以匹配的目录中的资源,但是不能加载到jar包中的资源
<property name="locations" value="file:d/tomcat6/bin/db.properties" />
在tomcat6下bin中的catalina.sh/catalina.bat 中 (或者jboss的run.sh/run.bat )文件中、java——opts的后面追加
-djdbc.properties=d:/tomcat6/bin/db.properties
<property name="locations" value="file:#{systemproperties['jdbc.properties']}" />
<property name="location"><value>file:${jdbc.properties}</value></property>