Java Spring启动-源不能为空

Java Spring启动-源不能为空,java,spring-boot,Java,Spring Boot,我创建了一个简单的Spring Boot应用程序,其中一个端点在users表中创建了一条新记录 然而,当我用Postman点击这个端点时,我得到了以下错误: java.lang.IllegalArgumentException: Source must not be null at org.springframework.util.Assert.notNull(Assert.java:198) ~[spring-core-5.2.1.RELEASE.jar:5.2.1.RELEASE]

我创建了一个简单的Spring Boot应用程序,其中一个端点在
users
表中创建了一条新记录

然而,当我用Postman点击这个端点时,我得到了以下错误:

java.lang.IllegalArgumentException: Source must not be null
    at org.springframework.util.Assert.notNull(Assert.java:198) ~[spring-core-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    at org.springframework.beans.BeanUtils.copyProperties(BeanUtils.java:693) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    at org.springframework.beans.BeanUtils.copyProperties(BeanUtils.java:639) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
    at com.demo.controller.UserController.createUser(UserController.java:45) ~[classes/:na]
问题是什么

编辑:

显然,它将记录保存在数据库中,但仍然返回一个错误。 以下是
UserController
的代码:

    @PostMapping
    public UserRest createUser(@RequestBody UserDetailsRequestModel userDetails) 
    {

        UserRest result = new UserRest();
        UserDto userDto = new UserDto();

        BeanUtils.copyProperties(userDetails, userDto);

        UserDto createdUser = userService.createUser(userDto);

        BeanUtils.copyProperties(createdUser, result);
        return result;
    }

JavaSpring断言参数不能为null。 正如您提到的,您正在调用方法

BeanUtils.copyProperties(createdUser, result)    at com.demo.controller.UserController.createUser(UserController.java:45) ~[classes/:na]
您只需确保值不为null

若您查看复制方法的源代码,您将发现检查不为null

Assert.notNull(source, "Source must not be null");
Assert.notNull(target, "Target must not be null");

JavaSpring断言参数不能为null。 正如您提到的,您正在调用方法

BeanUtils.copyProperties(createdUser, result)    at com.demo.controller.UserController.createUser(UserController.java:45) ~[classes/:na]
您只需确保值不为null

若您查看复制方法的源代码,您将发现检查不为null

Assert.notNull(source, "Source must not be null");
Assert.notNull(target, "Target must not be null");

在UserController.java的第45行中有什么?
BeanUtils.copyProperties(createdUser,result)UserController.java的第45行中有什么?
BeanUtils.copyProperties(createdUser,result)什么参数?@Gambit2007我假设createdUser和result都不能为null。@Gambit2007在您的案例消息中说Source所以看起来createdUser属性为null好的,知道了,让我检查一下。。(我还编辑了这个问题,如果有帮助的话)好吧,我很愚蠢。。(对春天来说是新的)
createUser
正在返回
null
。。。谢谢你的澄清!!什么参数?@Gambit2007我假设createdUser和result都不能为null。@Gambit2007在您的案例消息中说Source所以看起来您的createdUser属性为null好的,知道了,让我检查一下。。(我还编辑了这个问题,如果有帮助的话)好吧,我很愚蠢。。(对春天来说是新的)
createUser
正在返回
null
。。。谢谢你的澄清!!