最近在回顾spring配置
<!-- spring的标签 -->
<context:property-placeholder location="classpath:db.properties" />
<bean class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="configLocation" value="classpath:mybatis-config.xml" />
<property name="dataSource" ref="dataSource" />
</bean>
<!-- mybatis里面的标签 -->
<mappers>
<mapper resource="com/mapper/CountryMapper.xml" />
</mappers>
类似比如还有<bean class="..."/>,这个自己能相通,通过全限定名去找到class创建对象。
那么这些配置在加载文件的时候,为什么有些需要加classpath:... ,有些文件只需要配置包名+类名,比如上面加载mapper,类似于全限定名就能找到文件。
我的疑问,都是去找文件的配置,为什么会出现这个差别。
百度实在找不到,没人回答我只能这样想了,配置文件需要加classpath,代码直接全限定名就行了。