1.Caused by: org.springframework.beans.NotWritablePropertyException:
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property ‘runner’ of bean class [com.dao.AccountDaoImpl]: Bean property ‘runner’ is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
意思是在com.dao.AccountDaoImpl中缺少属性runner的setter方法。
或者说是setter方法不符合驼峰命名。
2.java.sql.SQLException: No suitable driver
Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.
原因(1) 很有可能这下面的数据错了
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<!--连接数据库的必备信息-->
<property name="driverClass" value="com.mysql.jdbc.Driver"></property>
<property name="jdbcUrl" value="jdbc:mysql//localhost:3306/Zzz"></property>
<property name="user" value="root"></property>
<property name="password" value="123456"></property>
</bean>
我的就是jdbc:mysql:// 少了一个冒号。
(2)还有一个也就是字面意思:你没有适用的驱动
3、Exception in thread “main” org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 37 in XML document from class path resource [bean.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 37; columnNumber: 84; cvc-complex-type.2.4.a: 发现了以元素 ‘aop:pointcut’ 开头的无效内容。应以 ‘{“http://www.springframework.org/schema/aop”:aspect}’ 之一开头。
Caused by: org.xml.sax.SAXParseException; lineNumber: 37; columnNumber: 84; cvc-complex-type.2.4.a: 发现了以元素 ‘aop:pointcut’ 开头的无效内容。应以 ‘{“http://www.springframework.org/schema/aop”:aspect}’ 之一开头。
Spring xml中导的约束规定切入点表达式必须写在切面前。
4、Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘service’ defined in class path resource [bean.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.Service]: No default constructor found; nested exception is java.lang.NoSuchMethodException: com.Service.()
Exception in thread “main” org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘service’ defined in class path resource [bean.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.Service]: No default constructor found; nested exception is java.lang.NoSuchMethodException: com.Service.()
问题所在:用XML创建bean对象时,用的是默认构造函数,但是此时如果类中没有默认构造函数