2009-10-10 131 views
0

我不知道爲什麼彈簧2.5.6一直在抱怨,但我沒有任何「orderBy」註釋。彈簧註釋配置問題

2009-10-10 13:55:37.242::WARN: Nested in org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.context.annotation.internalPersiste 
nceAnnotationProcessor': Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'order' of bean class [org.springfra 
mework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor]: Bean property 'order' is not writable or has an invalid setter method. Does the parameter type of the setter match the re 
turn type of the getter?: 
org.springframework.beans.NotWritablePropertyException: Invalid property 'order' of bean class [org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor]: Bean propert 
y 'order' 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:801) 
     at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:651) 
     at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:78) 
     at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:59) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1276) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010) 

,甚至當我換用低版本2.5.1春天,它仍然在抱怨:

2009-10-10 13:57:56.062::WARN: failed [email protected] 
java.lang.NoClassDefFoundError: org/springframework/context/support/AbstractRefreshableConfigApplicationContext 
     at java.lang.ClassLoader.defineClass1(Native Method) 
     at java.lang.ClassLoader.defineClass(ClassLoader.java:621) 
     at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124) 
     at java.net.URLClassLoader.defineClass(URLClassLoader.java:260) 
     at java.net.URLClassLoader.access$000(URLClassLoader.java:56) 
     at java.net.URLClassLoader$1.run(URLClassLoader.java:195) 
     at java.security.AccessController.doPrivileged(Native Method) 
     at java.net.URLClassLoader.findClass(URLClassLoader.java:188) 
     at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:366) 
     at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:337) 
     at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) 
     at java.lang.ClassLoader.defineClass1(Native Method) 
     at java.lang.ClassLoader.defineClass(ClassLoader.java:621) 
     at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124) 
     at java.net.URLClassLoader.defineClass(URLClassLoader.java:260) 
     at java.net.URLClassLoader.access$000(URLClassLoader.java:56) 
     at java.net.URLClassLoader$1.run(URLClassLoader.java:195) 
     at java.security.AccessController.doPrivileged(Native Method) 
     at java.net.URLClassLoader.findClass(URLClassLoader.java:188) 
     at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:366) 
     at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:337) 
     at org.springframework.util.ClassUtils.forName(ClassUtils.java:230) 
     at org.springframework.util.ClassUtils.forName(ClassUtils.java:183) 
     at org.springframework.web.context.ContextLoader.determineContextClass(ContextLoader.java:283) 
     at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:243) 

如果我不使用註釋,它工作正常。一點問題都沒有,

這一切

<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:context="http://www.springframework.org/schema/context" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
     http://www.springframework.org/schema/beans/spring-beans-2.5.xsd 
     http://www.springframework.org/schema/context 
     http://www.springframework.org/schema/context/spring-context-2.5.xsd" 
    default-autowire="byName"> 

    <context:component-scan base-package="demo.dao"> 
     <context:include-filter type="annotation" 
      expression="org.springframework.stereotype.Repository"/> 
    </context:component-scan> 
</beans> 

發生後,我相信我的春天的配置是否正確。

<?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:aop="http://www.springframework.org/schema/aop" 
     xmlns:util="http://www.springframework.org/schema/util" 
     xmlns:context="http://www.springframework.org/schema/context" 
     xmlns:tx="http://www.springframework.org/schema/tx" 
     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd 
          http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd 
          http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd 
          http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd 
          http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd" 
     default-autowire="byName"> 

    <!-- For mail settings and future properties files --> 
    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> 
     <property name="locations"> 
      <list> 
       <value>classpath:jdbc.properties</value> 
      </list> 
     </property> 
    </bean> 

    <!-- Check all the beans managed by Spring for persistence-related annotations. e.g. PersistenceContext --> 
    <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" /> 

    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> 
     <property name="driverClassName" value="${jdbc.driverClassName}"/> 
     <property name="url" value="${jdbc.url}"/> 
     <property name="username" value="${jdbc.username}"/> 
     <property name="password" value="${jdbc.password}"/> 
    </bean> 

    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> 
     <property name="dataSource" ref="dataSource"/> 

     <!-- jpaVendorAdapter Hibernate, injected into emf --> 
     <property name="jpaVendorAdapter"> 
      <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> 
       <property name="showSql" value="${hibernate.show_sql}"/> 
       <!-- Data Definition Language script is generated and executed for each run --> 
       <property name="generateDdl" value="${jdbc.generateDdl}"/> 
      </bean> 
     </property> 

     <!--<property name="hibernateProperties"> --> 
     <property name="jpaProperties"> 
      <props> 
       <prop key="hibernate.dialect">${hibernate.dialect} 
       </prop> 
       <prop key="hibernate.show_sql">${hibernate.show_sql}</prop> 
       <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto} 
       </prop> 
      </props> 
     </property> 
    </bean> 

    <tx:annotation-driven transaction-manager="transactionManager" /> 
    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> 
     <property name="entityManagerFactory" ref="entityManagerFactory"/> 
     <property name="dataSource" ref="dataSource"/> 
    </bean> 
</beans> 

誰能告訴我什麼是錯的?我怎樣才能解決這個問題?

+0

可能是自動裝配發生了一些奇怪的事情 - 您是否嘗試刪除autowire byName並手動執行? – 2009-10-10 03:19:58

+0

同樣的事情再次發生....後,我刪除'byName' – jojo 2009-10-10 03:31:54

+0

代碼在哪裏? – 2012-01-04 14:41:50

回答

1

我在將Spring遷移到新版本時遇到同樣的問題。
尋找流氓JAR -files舊版本。
在我的情況下,它是由jaxws-springmaven引入的依賴項。