4
當我創建Spring-config xml時,添加dataSource時出現錯誤,它說無法解析bean。無法解析bean驅動程序ClassName
我spring.xml
是:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://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">
<context:component-scan base-package="com.dqbz" />
<!-- 配置整合mybatis過程 -->
<!-- 1.配置數據庫相關參數properties的屬性:${url} -->
<context:property-placeholder location="classpath:jdbc.properties" />
<!-- 2.數據庫連接池 -->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<!-- 基本屬性driverClassName、 url、user、password -->
<property name="driverClassName" value="${jdbc.driver}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>
</beans>
這應該是一個評論,因此它不回答這個問題。 –
我很高興你很快就能得出結論@YassinHajaj。在查看配置時,我可以看到沒有其他問題 - 並且基於帖子的標題,它抱怨一個名爲「driverClassName」的bean。評論中還有中文字符。誰知道如何解析。 – neal
只要文檔的其餘部分在語義上正確,XML並不關心您在哪裏粘貼註釋。 – Makoto