这是spring的配置文件<?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:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="oracle.jdbc.driver.OracleDriver">
</property>
<property name="url"
value="jdbc:thin:@localhost:1521/orcl">
</property>
<property name="username" value="orcl"></property>
<property name="password" value="orcl"></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.DerbyDialect
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/test/vo/UserInfo.hbm.xml</value></list>
</property></bean>
<bean id="userinfodaoimpl" class="com.test.dao.UserInfoDaoImpl">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="userinfoservice"  class="com.test.service.UserInfoServiceImpl">
<property name="userinfodaoimpl"> //这样提示红叉Invalid property name 'UserInfoDao' - not JavaBean compliant 
<ref bean="userinfodaoimpl"/>
</property>
</bean>

</beans>
com.test.service.UserInfoServiceImpl类内容package com.test.service;import java.util.List;import com.test.dao.UserInfoDaoImpl;
import com.test.vo.UserInfoVO;public class UserInfoServiceImpl implements UserInfoService{


private UserInfoDaoImpl userinfodaoimpl;

public UserInfoDaoImpl getUserinfodaoimpl() {
return userinfodaoimpl;
} public void setUserinfodaoimpl(UserInfoDaoImpl userinfodaoimpl) {
this.userinfodaoimpl = userinfodaoimpl;
} @Override
public boolean Login(UserInfoVO uiVO) {
// TODO Auto-generated method stub
List list = userinfodaoimpl.findByUserName(uiVO);
if(list!=null&&list.size()>0)
return true;
return false;
}


}麻烦大家帮我看一下 这个错误是什么原因导致的

解决方案 »

  1.   

    你的配置文件中没有UserInfoDao呀,把该文件关闭,然后重新打开问题也许就没了,编译一下看看是否仍然报错。其实显示红叉没什么,只要能运行、不出错就OK。你试试运行是否报错,如果出错,请把异常信息贴出来
      

  2.   

    log4j:WARN No appenders could be found for logger (org.springframework.context.support.ClassPathXmlApplicationContext).
    log4j:WARN Please initialize the log4j system properly.
    Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userinfoservice' defined in class path resource [applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'userinfodao' of bean class [com.test.service.UserInfoServiceImpl]: Bean property 'userinfodao' 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.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1344)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1067)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:562)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:871)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
    at com.test.service.UserInfoServiceImpl.main(UserInfoServiceImpl.java:36)
    Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'userinfodao' of bean class [com.test.service.UserInfoServiceImpl]: Bean property 'userinfodao' 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:1012)
    at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:857)
    at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:76)
    at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1341)
    ... 13 more这是错误信息。 我读取xml运行的
      

  3.   

     <bean id="userinfoservice"  class="com.test.service.UserInfoServiceImpl">
            <property name="userinfodaoimpl"> //这样提示红叉Invalid property name 'UserInfoDao' - not JavaBean compliant 
            <ref bean="userinfodaoimpl"/>
            </property>
        </bean>按Ctrl 点击下设置的属性,看看是否能够进入<property name="userinfodaoimpl"> <ref bean="userinfodaoimpl"/>
    都点一下,假如是能注入肯定是能点击查找的,就跟java的类、方法一样
      

  4.   

    谢谢你帮助 我解决了 重启myeclipse也没反应 剪切再粘回去就好了。。真让人抓狂。 啥毛病没有我在这找了一下午。