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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

Spring Boot 無(wú)法從 MySQL 數(shù)據(jù)庫(kù)中獲取和顯示數(shù)據(jù)

Spring Boot 無(wú)法從 MySQL 數(shù)據(jù)庫(kù)中獲取和顯示數(shù)據(jù)

吃雞游戲 2023-05-10 15:37:52
我最近一直在開(kāi)發(fā)一個(gè) Spring Boot 項(xiàng)目,該項(xiàng)目以 JSON 格式更新和從 MySQL 數(shù)據(jù)庫(kù)中獲取數(shù)據(jù),但是當(dāng)我運(yùn)行我的應(yīng)用程序時(shí),我有一個(gè)錯(cuò)誤頁(yè)面:[我瀏覽器上的錯(cuò)誤截圖][1] [1]: https://i.stack.imgur.com/CkYmr.png我的實(shí)體類是:package com.project.project.entities;import javax.persistence.*;import java.io.Serializable;import java.util.List;@Entity@Table(name = "products")// why serializable ?? every entity in JPA is automatically-serializable,  connection between different networkspublic class Product implements Serializable {    @Id    @GeneratedValue(strategy = GenerationType.IDENTITY) // assign a unique value to your identity field automatically    private Long id;    private String designation;    private int price;    private int quantity;    private int category_id;    // the owning side of the relationship, side of the foreign key    @ManyToOne(fetch = FetchType.LAZY )// many products to one category    @JoinColumn(name = "category_id" , insertable = false , updatable = false)    // means that the product table will have a fk_column named...    private Category category;    // categoryId foreign key referencing to the primary key on Category    // Double and Integer in case both variables are unknown -> Category constructor    public Product(Long id, String designation, Integer price, Integer quantity, int categor_id) {        this.id = id;        this.designation = designation;        this.price = price;        this.quantity = quantity;        this.category_id = category_id;    }我的存儲(chǔ)庫(kù):import com.project.project.entities.Product;import org.springframework.data.jpa.repository.JpaRepository;import org.springframework.stereotype.Repository;@Repositorypublic interface ProductRepository extends JpaRepository<Product,Long> {}
查看完整描述

1 回答

?
慕標(biāo)琳琳

TA貢獻(xiàn)1830條經(jīng)驗(yàn) 獲得超9個(gè)贊

@Controller只需在控制器上設(shè)置as 注釋即可。


//imports


@Controller

public class ProductRestController {


? ? @Autowired

? ? ProductService productService;


? ? //GetMapping etc



}

@RestController您也可以使用注釋。



查看完整回答
反對(duì) 回復(fù) 2023-05-10
  • 1 回答
  • 0 關(guān)注
  • 187 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)