开发者社区> 问答> 正文

spring配置自动代理后启动报错:报错

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'studentAction' defined in ServletContext resource [/WEB-INF/applicationContext_bean.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy1] to required type [cn.sjh.service.impl.StudentServiceImpl] for property 'stuSI'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy1] to required type [cn.sjh.service.impl.StudentServiceImpl] for property 'stuSI': no matching editors or conversion strategy found
Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessException details (1) are:
PropertyAccessException 1:
org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy1] to required type [cn.sjh.service.impl.StudentServiceImpl] for property 'stuSI'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy1] to required type [cn.sjh.service.impl.StudentServiceImpl] for property 'stuSI': no matching editors or conversion strategy found
Caused by: java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy1] to required type [cn.sjh.service.impl.StudentServiceImpl] for property 'stuSI': no matching editors or conversion strategy found
 at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:231)
 at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:138)
 at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:815)
 at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:645)
 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:1122)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:857)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:423)
 at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)
 at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)
 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)
 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
 at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:291)
 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
 at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:245)
 at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:188)
 at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
 at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3934)
 at org.apache.catalina.core.StandardContext.start(StandardContext.java:4429)
 at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
 at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
 at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526)
 at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:987)
 at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:909)
 at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:495)
 at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1206)
 at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:314)
 at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
 at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
 at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
 at org.apache.catalina.core.StandardService.start(StandardService.java:516)
 at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
 at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
 at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
2012-6-16 9:07:53 org.apache.catalina.core.StandardContext start
严重: Error listenerStart
2012-6-16 9:07:53 org.apache.catalina.core.StandardContext start
严重: Context [/sjh_ssh_dom] startup failed due to previous errors
2012-6-16 9:07:53 org.apache.catalina.core.ApplicationContext log
信息: Closing Spring root WebApplicationContext
2012-6-16 9:07:58 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.
2012-6-16 9:08:07 org.apache.coyote.http11.Http11Protocol start
信息: Starting Coyote HTTP/1.1 on http-8686
2012-6-16 9:08:07 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009

下面是部分配置文件

<?xml version="1.0" encoding="GB18030"?>
<beans
 xmlns="http://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:tx="http://www.springframework.org/schema/tx"
 xmlns:aop="http://www.springframework.org/schema/aop"
 xmlns:p="http://www.springframework.org/schema/p"
 xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
      http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
      http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
 
 
 <!-- 定义通知 -->
 <bean id="alogger" class="cn.sjh.Advice.impl.LogAfterAdvice">
 
  <property name="logService" ref="logService"></property>
 </bean>
 <!--
 <bean id="blogger" class="cn.test.service.impl.BeforeAdvice"></bean>
 <bean id="mlogger" class="cn.test.service.impl.MethodAdvisor"></bean>-->
 
 
 <!-- 定义代理 -->
 <bean id="shoppingPointCutAdvisor" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
   <property name="beanNames">
     <list>
      <value>studentService</value>
     </list>
   </property>
  
   <property name="interceptorNames">
     <list>
       <value>alogger</value>
     </list>
   </property>
 </bean>
 
 <!-- 配置事务管理器-->
 <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
  <property name="sessionFactory">
   <ref bean="sessionFactory"/>
  </property> 
 </bean>
 
 <!-- 配置事务的传播特性 即事务的应用规则-->
 <tx:advice id="txAdvice" transaction-manager="transactionManager">
  <tx:attributes>
   <tx:method name="asdassave*" propagation="REQUIRED" rollback-for="Throwable"/>
   <tx:method name="del*" propagation="REQUIRED" rollback-for="Throwable"/>
   <tx:method name="modify*" propagation="REQUIRED" rollback-for="Throwable"/>
   
  </tx:attributes>
 </tx:advice>
 
 <!-- 那些类的哪些方法参与事务 -->
 <aop:config>
  <aop:pointcut id="allManagerMethod" expression="execution(* cn.test.service.impl.*.*(..))"/>
  <aop:advisor pointcut-ref="allManagerMethod" advice-ref="txAdvice"/>
 </aop:config>
 
 
 <!-- Dao层配置 -->
 <bean id="studentDao" class="cn.sjh.dao.impl.StudentDaoImpl">
  <property name="sessionFactory">
   <ref bean="sessionFactory"/>
  </property>
 </bean>
 
 <bean id="logDao" class="cn.sjh.dao.impl.LogDaoImpl">
  <property name="sessionFactory">
   <ref bean="sessionFactory"/>
  </property>
 </bean>
 
 <!-- Service层配置 -->
 <bean id="logService" class="cn.sjh.service.impl.LogServiceImpl">
  <property name="log_dao" ref="logDao"></property>
 </bean>
 
 
 <bean id="studentService" class="cn.sjh.service.impl.StudentServiceImpl">
  <property name="stuDao" ref="studentDao"></property>
 </bean>
 
 
 <!-- Action层配置 -->
 <bean id="studentAction" class="cn.sjh.action.StudentAction">
  <property name="stuSI" ref="studentService"></property>
 </bean> 
 </beans>

 

下面是service层代码

package cn.sjh.service.impl;
import java.util.List;

import cn.sjh.beans.*;
import cn.sjh.dao.impl.*;
import cn.sjh.service.*;
public class StudentServiceImpl implements IMyService {
 private StudentDaoImpl stuDao;
 
 public void delete(Object o) {
  stuDao.delete(o);
 }

 public PageBean findAll(int start, int size) {
  return stuDao.findAll(start, size);
 }

 public Object save(Object o) {
  return stuDao.save(o);
 }

 public Object update(Object o) {
  return stuDao.update(o);
 }

 public StudentDaoImpl getStuDao() {
  return stuDao;
 }

 public void setStuDao(StudentDaoImpl stuDao) {
  this.stuDao = stuDao;
 }
 
}

 

下面是action代码

package cn.sjh.action;

import java.util.*;
import java.sql.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.interceptor.*;
import com.opensymphony.xwork2.*;

import cn.sjh.service.impl.*;
import cn.sjh.service.*;
import cn.sjh.beans.*;
public class StudentAction extends ActionSupport implements ServletRequestAware,ServletResponseAware {
 private HttpServletRequest request;
 private HttpServletResponse response;
 private int total;
 private int page;
 private int row;
 private TStudent stu;
 private List rows;
 private IMyService stuSI;
 private String resultMsg;
 
 public String findAll()throws Exception{
   this.resultMsg=null;
   this.row=Integer.parseInt(request.getParameter("rows"));
   PageBean pb=stuSI.findAll(getStart(), row);
   this.setRows(pb.getRows());
   this.setTotal(pb.getTotal());
   System.out.println(rows.size());
   /*List lt=this.rows;
   for(int i=0;i<lt.size();i++){
    Map mp=(Map)lt.get(i);
    System.out.println(mp);
   }*/
  return SUCCESS;
 }
 public void update()throws Exception{
  System.out.println(stu.getName()+"同学年龄"+stu.getAge()+"性别"+stu.getSex()+"电话"+stu.getPhone());
  Object o=stuSI.update(this.stu);
  if(o!=null){
   this.resultMsg="学生信息修改成功";
  }else{
   this.resultMsg="学生信息修改成功";
  }
  response.setContentType("text/html;charset=UTF-8");
  response.getWriter().write(this.resultMsg);
 }
 
 
 
 public int getStart(){
  int start=(page-1)*row;
  return start;
 }
 public void setServletRequest(HttpServletRequest arg0) {
  // TODO Auto-generated method stub
  this.request=arg0;
 }
 public void setServletResponse(HttpServletResponse arg0) {
  // TODO Auto-generated method stub
  this.response=arg0;
 }
 public int getTotal() {
  return total;
 }
 public void setTotal(int total) {
  this.total = total;
 }
 public int getPage() {
  return page;
 }
 public void setPage(int page) {
  this.page = page;
 }
 public int getRow() {
  return row;
 }
 public void setRow(int row) {
  this.row = row;
 }
 public void setStu(TStudent stu) {
  this.stu = stu;
 }
 public List getRows() {
  return rows;
 }
 public void setRows(List rows) {
  this.rows = rows;
 }
 public void setStuSI(StudentServiceImpl stuSI) {
  this.stuSI = stuSI;
 }
 public String getResultMsg() {
  return resultMsg;
 }
 public void setResultMsg(String resultMsg) {
  this.resultMsg = resultMsg;
 }
 public TStudent getStu() {
  return stu;
 }
}

展开
收起
kun坤 2020-06-06 22:32:41 450 0
1 条回答
写回答
取消 提交回答
  • 不加代理部分的配置就没事,加上去启动就报错

    2020-06-06 22:32:49
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
云栖社区特邀专家徐雷Java Spring Boot开发实战系列课程(第20讲):经典面试题与阿里等名企内部招聘求职面试技巧 立即下载
微服务架构模式与原理Spring Cloud开发实战 立即下载
阿里特邀专家徐雷Java Spring Boot开发实战系列课程(第18讲):制作Java Docker镜像与推送到DockerHub和阿里云Docker仓库 立即下载

相关实验场景

更多