Caused by: java.io.FileNotFoundException: class path resource [applicationContext.xml] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:158)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:329)
配置文件找不到:
解决:
右键项目---->properties--->Java Build Path--->source--->Add Folder --->选择conf文件夹
Caused by: java.lang.NoSuchMethodException: com.mod.Person.()
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.getDeclaredConstructor(Unknown Source)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:80)
… 14 more
解决:
在bean类里面加一个无参的构造方式即可
例:
public Person() {
super();
// TODO Auto-generated constructor stub
}
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property ‘jdbcurl’ of bean class [com.alibaba.druid.pool.DruidDataSource]: Bean property ‘jdbcurl’ is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:1076)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:927)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:95)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:75)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1510)
… 41 more“
Druid的数据源的
<property name="url" value="${jdbc.url}"></property>
<property name="username" value="${jdbc.username}"></property>
<property name="password" value="${jdbc.password}"></property>
的name属性的值要改成指定名称。比如:把jdbcurl换成url、username必须一样、password也是
通配符的匹配很全面, 但无法找到元素 'context:property-placeholder' 的声明。
在Spring配置文件中出现通配符的匹配很全面, 但无法找到元素 'context:property-placeholder' 的声明这个错误,其实主要是我们在引入命名空间时没有正确引入它的DTD解析文件,当然你必须在把Spring相应的包导入正确的情况下。
解决方案就是如下:
xmlns:context="http://www.springframework.org/schema/context"
同时在xsi:schemaLocation这个字符串中添加context相关的解析文件
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.2.xsd。
其他的如util命名空间导入方式一样,只是把context换成相应util就可以了。
Exception in thread “main” org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named ‘userController’ is defined
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:638)
at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1159)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:282)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:979)
at com.spring.test.test.main(test.java:11)
没有任何一个bean可以为他自动装配,要么没加注解要么配置文件中包写错了
Caused by: java.lang.IllegalArgumentException: Pointcut is not well-formed: expecting ‘)’ at character position 16
exection(public int com.spring.aop.aspectj.mathImpl.add(int, int))
^^^
注解中写错了,execution写成exection了