Adesso il mio XML l'ho modificato così:
codice:
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/library" />
<property name="username" value="UTENTE" />
<property name="password" value="PASSWORD" />
</bean>
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="dataSource" />
</bean>
In Mysql ho creato un DB chiamato library e la tabella books come richiesto nell'esempio.
Ma ecco i guai:
org.springframework.beans.factory.xml.XmlBeanDefin itionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [beans.xml]
Exception in thread "main" org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'bookDao' defined in class path resource [beans.xml]: Cannot resolve reference to bean 'jdbcTemplate' while setting bean property 'jdbcTemplate'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'jdbcTemplate' defined in class path resource [beans.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'dataSource' defined in class path resource [beans.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateExcep tion; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationExceptio n: Property 'driverClassName' threw exception; nested exception is java.lang.IllegalStateException: Could not load JDBC driver class [com.mysql.jdbc.Driver]
...
Se qualcuno leggendo l'errore individua facilmente la soluzione va bene, altrimenti capisco che una cosa del genere deve essere una gran rottura di scatole da leggere
Grazie in ogni caso