0
我的dao實現;spring dataSource config。與註釋
\\here are imports...
@Repository
public class CompanyDaoImp extends JdbcDaoSupport implements CompanyDao {
private static final String INSERTCOMPANY = "INSERT INTO b_company"
+ "(NAME)VALUES(?)";
這是我的豆;
<?xml version=".........
<!-- TODO add the component-scan and annotation-config elements -->
<context:annotation-config/>
<context:component-scan base-package="com.some.company"/>
<bean id="companyAppDataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/companyapp"/>
<property name="username" value="root"/>
<property name="password" value="root"/>
</bean>
</beans>
我不明白爲什麼我一直採取例外; .......調用init方法失敗;嵌套異常是java.lang.IllegalArgumentException:'dataSource'或'jdbcTemplate'是必需的.........
我認爲setDataSource是最終的,所以我不能重寫它。第二個sol。工作,但有沒有什麼辦法可以做到這一點只有註釋(數據源bean除外) – cek
@cek你說得對。我沒有注意到。我在答案中刪除了這個。抱歉。 – LaurentG
沒問題。你認爲如果我在定義數據源bean時犯了錯誤嗎? – cek