Spring-mvc<!--?配置文件?--><bean?id="configProperty"class="org.springframework.beans.factory.config.PropertiesFactoryBean"><property?name="locations"><list><value>classpath*:setting.properties</value></list></property></bean><!--?配置信息?--><bean?id="propertyConfigurer"class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"><property?name="ignoreResourceNotFound"?value="false"?/><property?name="properties"?value="configProperty"?/></bean>Spring-Mybatis<!--?配置數(shù)據(jù)源?--><bean?id="dataSource"?class="org.apache.commons.dbcp2.BasicDataSource"destroy-method="false"><property?name="driverClassName"><value>${db.driver}</value></property><property?name="url"><value>${db.url}</value></property><property?name="username"><value>${db.username}</value></property><property?name="password"><value>${db.password}</value></property><property?name="initialSize"><value>5</value></property><property?name="maxTotal"><value>50</value></property><property?name="maxWaitMillis"><value>60000</value></property><property?name="maxIdle"><value>20</value></property><property?name="connectionProperties"><value>clientEncoding=UTF-8</value></property></bean><!--?創(chuàng)建?sqlSessionFactory?--><bean?id="sqlSessionFactory"?class="org.mybatis.spring.SqlSessionFactoryBean"><property?name="dataSource"?ref="dataSource"?/><property?name="configLocation"?value="classpath:mybatis-config.xml"?/></bean>setting.propertiesdb.driver=com.mysql.jdbc.Driverdb.url=jdbc:mysql://localhost:3306/live?useUnicode=true&characterEncoding=utf-8db.username=rootdb.password=rooteclipse 報錯Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'dataSource' defined in class path resource [spring-mybatis.xml]: Could not resolve placeholder 'db.driver' in string value "${db.driver}"; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'db.driver' in string value "${db.driver}"
maven項目無法讀取配置文件
遠(yuǎn)飛的小馬
2017-01-05 00:39:10