Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/385.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 正在将数据插入到“中/从中提取”;春季“布特克鲁德”;表而不是实际表;DbTable";在Spring引导应用程序中_Java_Spring_Spring Boot_Spring Data Jpa_Postman - Fatal编程技术网

Java 正在将数据插入到“中/从中提取”;春季“布特克鲁德”;表而不是实际表;DbTable";在Spring引导应用程序中

Java 正在将数据插入到“中/从中提取”;春季“布特克鲁德”;表而不是实际表;DbTable";在Spring引导应用程序中,java,spring,spring-boot,spring-data-jpa,postman,Java,Spring,Spring Boot,Spring Data Jpa,Postman,这是POJO类,我在注释中提到了表名: @Entity @Table(name = "DbTable") @Getter @Setter @NoArgsConstructor @AllArgsConstructor @ToString public class SimplePOJO { @Id @GeneratedValue private int id; private String name; } 这是控制器类: @RestCont

这是POJO类,我在注释中提到了表名:

@Entity
@Table(name = "DbTable")
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class SimplePOJO {   
    @Id
    @GeneratedValue
    private int id;
    private String name;
}
这是控制器类:

@RestController
@RequestMapping("/Myapp")
public class SimpleController {
    
    @Autowired
    SimpleDao dao; \\ public interface SimpleDao extends CrudRepository<SimplePOJO, Integer>{}
    
    @PostMapping("/Create")
    public String enterData(@RequestBody List<SimplePOJO> spojo){       
        dao.saveAll(spojo);
        return "Number of records entered: "+ spojo.size();
    }
    
    @GetMapping("/Read")
    public List<SimplePOJO> getData() {
        return (List<SimplePOJO>) dao.findAll();
    }
}
现在,在运行应用程序后,我使用postman应用程序点击URL:

POST request> https://localhost:8080/Myapp/Create
Body:
[
    {
        "name":"fst nme"
    },
    {
        "name":"last nme"
    }
]

Response 200: Number of records entered: 2
下面是eclipse控制台日志:

Hibernate: select next value for hibernate_sequence
Hibernate: select next value for hibernate_sequence
Hibernate: insert into spring_bootcrud (name, id) values (?, ?)
Hibernate: insert into spring_bootcrud (name, id) values (?, ?)
Hibernate: select next value for hibernate_sequence
Hibernate: select next value for hibernate_sequence
Hibernate: insert into spring_bootcrud (name, id) values (?, ?)
Hibernate: insert into spring_bootcrud (name, id) values (?, ?)

现在,在MSsql数据库“TestCRUD”中,一个新表“spring_bootcrud”正在创建中,name列被“NULL”填充。我不知道这个“spring\u bootcrud”表是如何创建的。请帮忙!我是Spring Boot的初学者。

不要使用Spring.jpa.hibernate.ddl-auto=validate属性。在开发中,建议使用validate值(但我仍然希望控制数据库,所以我将其设置为none,或者甚至不使用它)。在生产中,将其设置为“无”,甚至不编写它。
Hibernate: select next value for hibernate_sequence
Hibernate: select next value for hibernate_sequence
Hibernate: insert into spring_bootcrud (name, id) values (?, ?)
Hibernate: insert into spring_bootcrud (name, id) values (?, ?)
Hibernate: select next value for hibernate_sequence
Hibernate: select next value for hibernate_sequence
Hibernate: insert into spring_bootcrud (name, id) values (?, ?)
Hibernate: insert into spring_bootcrud (name, id) values (?, ?)