iT邦幫忙

0

Springboot 加入建構子報錯

  • 分享至 

  • xImage

如標題

package tw.chen.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import org.springframework.stereotype.Component;

@Entity@Table(name = "Show")
@Component
public class Show {
	
	@Id@Column(name = "id")
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private int id;
	private String title;
	private String name;
	private String sdate;
	private String edate;
	private String price;
	private String picture;
	
	public Show(int id, String title, String name, String sdate, String edate, String price, String picture) {
		this.id = id;
		this.title = title;
		this.name = name;
		this.sdate = sdate;
		this.edate = edate;
		this.price = price;
		this.picture = picture;
	}
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getSdate() {
		return sdate;
	}
	public void setSdate(String sdate) {
		this.sdate = sdate;
	}
	public String getEdate() {
		return edate;
	}
	public void setEdate(String edate) {
		this.edate = edate;
	}
	public String getPrice() {
		return price;
	}
	public void setPrice(String price) {
		this.price = price;
	}
	public String getPicture() {
		return picture;
	}
	public void setPicture(String picture) {
		this.picture = picture;
	}
	
}

https://ithelp.ithome.com.tw/upload/images/20220120/20143167qMfIYwdwHa.jpg

這樣建構Bean會直接報錯原因是甚麼?
請各位大神幫忙解答/images/emoticon/emoticon02.gif

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

0
史帝夫
iT邦新手 2 級 ‧ 2022-01-20 10:48:10
最佳解答
  1. 拿掉 @Component 試試
  2. 若不行就再加上 public Show(){} 試試
baye3313 iT邦新手 5 級 ‧ 2022-01-20 11:18:17 檢舉

感謝加入空的建構子就可以了/images/emoticon/emoticon12.gif

我要發表回答

立即登入回答