血色蒼穹 2016-08-24 07:46 采纳率: 0%
浏览 84670
已结题

java.lang.IllegalArgumentException求大神帮帮忙!!!

异常提示:Servlet.service() for servlet [dispatcher] in context with path [/comsed1] threw exception [Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessApiUsageException: Bean object must not be null; nested exception is java.lang.IllegalArgumentException: Bean object must not be null] with root cause
java.lang.IllegalArgumentException: Bean object must not be null
at org.springframework.util.Assert.notNull(Assert.java:112)
at org.springframework.beans.BeanWrapperImpl.setWrappedInstance(BeanWrapperImpl.java:213)
at org.springframework.beans.BeanWrapperImpl.setWrappedInstance(BeanWrapperImpl.java:202)
at org.springframework.beans.BeanWrapperImpl.(BeanWrapperImpl.java:151)
at org.springframework.data.util.DirectFieldAccessFallbackBeanWrapper.(DirectFieldAccessFallbackBeanWrapper.java:35)
at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.getId(JpaMetamodelEntityInformation.java:117)
at org.springframework.data.repository.core.support.AbstractEntityInformation.isNew(AbstractEntityInformation.java:51)
at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.isNew(JpaMetamodelEntityInformation.java:196)
at org.springframework.data.jpa.repository.support.SimpleJpaRepository.save(SimpleJpaRepository.java:376)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:405)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:390)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:344)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:98)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:262)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodIntercceptor.invoke(CrudMethodMetadataPostProcessor.java:111)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
at com.sun.proxy.$Proxy136.save(Unknown Source)
at iot.service.ProductMasterService.modifyProductMaster(ProductMasterService.java:32)
at iot.controller.productMasterController.modifyProductMaster(productMasterController.java:95)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

代码部分:
@RequestMapping(value = "modifyProductMasterInit")
public String modifyProductMasterInit(@RequestParam("productId") String productId,Model model){

// Iterable productMasterList = productMasterDAO.findByProductId(productId);
// model.addAttribute("productMasterList", productMasterList);
ProductMaster productMaster = this.productMasterService.findByProductId(productId);
model.addAttribute("productMaster", productMaster);
return "productMaster/Pro_Master_modify";
}

@RequestMapping(value = "modifyProductMaster")
public String modifyProductMaster(ProductMaster productMaster,@RequestParam("productId") String productId){

    ProductMaster productMasterOld = this.productMasterService.findByProductId(productId);//经断点调试productMasterOld为空
    try {
        BeanUtils.copyProperties(productMaster, productMasterOld);
    } catch (Exception e) {
        e.printStackTrace();
    }
    this.productMasterService.modifyProductMaster(productMasterOld);

    return "redirect:/productMaster/loadProductMaster";
}

    Service方法:
    @Service

public class ProductMasterService {

@Autowired(required = false)
private ProductMasterDAO productMasterDAO;

public void addproductMaster(ProductMaster productMaster) {
    this.productMasterDAO.save(productMaster);
}

public ProductMaster findByProductId(String productId) {
    return this.productMasterDAO.findByProductId(productId);
}

public void modifyProductMaster(ProductMaster productMaster) {
    this.productMasterDAO.save(productMaster);
}

}

ProductMasterDAO部分:
public interface ProductMasterDAO extends PagingAndSortingRepository,JpaSpecificationExecutor{

@Query("SELECT p FROM ProductMaster p WHERE p.productId = ?1")
public ProductMaster findByProductId(String productId);

}

  • 写回答

4条回答 默认 最新

  • 星之火燎原 2016-08-24 07:54
    关注

    ProductMasterDAO需要在application配置,另外,ProductMasterService 引用ProductMasterDAO要提供set方法,希望采纳

    评论

报告相同问题?

悬赏问题

  • ¥15 fpga自动售货机数码管(相关搜索:数字时钟)
  • ¥20 Python安装cvxpy库出问题
  • ¥15 用前端向数据库插入数据,通过debug发现数据能走到后端,但是放行之后就会提示错误
  • ¥15 python天天向上类似问题,但没有清零
  • ¥30 3天&7天&&15天&销量如何统计同一行
  • ¥30 帮我写一段可以读取LD2450数据并计算距离的Arduino代码
  • ¥15 C#调用python代码(python带有库)
  • ¥15 活动选择题。最多可以参加几个项目?
  • ¥15 飞机曲面部件如机翼,壁板等具体的孔位模型
  • ¥15 vs2019中数据导出问题