第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

無法將第二個實體添加到 Spring 數據啟動項目

無法將第二個實體添加到 Spring 數據啟動項目

LEATH 2023-04-19 16:17:33
我從https://spring.io/guides/gs/accessing-data-jpa/獲得了 Spring Data JPA 入門項目。我可以創(chuàng)建Customer和CustomerRepository類并使Customer實體持久存在。但是,當我添加另一個實體Person和 aPersonRepository并嘗試保留該實體時,出現(xiàn)如下所示的錯誤。就像在內部Application.java有某種內部類$1,Spring 數據試圖將其映射為一個實體。java.lang.IllegalArgumentException: 未知實體: hello.Application$1package hello;import lombok.Data;import lombok.NoArgsConstructor;import lombok.ToString;import javax.persistence.Entity;import javax.persistence.GeneratedValue;import javax.persistence.GenerationType;import javax.persistence.Id;@Entity@ToString@NoArgsConstructor@Datapublic class Person {    @Id    @GeneratedValue(strategy = GenerationType.AUTO)    private Long id;    private int age;}package hello;import org.springframework.data.repository.CrudRepository;public interface PersonRepository extends CrudRepository<Person, Long> {}package hello;import lombok.extern.slf4j.Slf4j;import org.springframework.boot.CommandLineRunner;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.context.annotation.Bean;@SpringBootApplication@Slf4jpublic class Application {    public static void main(String[] args) {        SpringApplication.run(Application.class);    }    /*    @Bean    public CommandLineRunner demo(CustomerRepository repository) {        return (args) -> {            repository.save(new Customer("Jack", "Bauer"));            repository.save(new Customer("Chole", "O'Brian"));            repository.save(new Customer("Kim", "Bauer"));            repository.save(new Customer("David", "Palmer"));            repository.save(new Customer("Michelle", "Dessler"));            // fetch all customers            log.info("Customers found with findAll():");            log.info("-------------------------------");            repository.findAll().forEach(c -> log.info(c.toString()));        };    }    */
查看完整描述

目前暫無任何回答

  • 0 回答
  • 0 關注
  • 109 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號