Error:(7, 1) java: 已在类 test192.pojo.Car中定义了构造器 Car(int,java.lang.String,double)
Car.java
package test192.pojo;
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
@AllArgsConstructor
public class Car {
private int carId;
private String carName;
private double carPrice;
public Car(int i, String carName, double v) {
this.carId=i;
this.carName=carName;
this.carPrice=v;
}
}
Data.java
package test192.config;
import test192.pojo.Car;
import java.util.ArrayList;
import java.util.List;
public class Data {
public static List<Car> list=new ArrayList<Car>();
static {
list.add(new Car(1, "carName1", 33.3));
list.add(new Car(2, "carName2", 33.3));
list.add(new Car(3, "carName3", 33.3));
}
}
解决方法:去掉@AllArgsConstructor
Car.java变成:
package test192.pojo;
import lombok.Data;
@Data
public class Car {
private int carId;
private String carName;
private double carPrice;
public Car(int i, String carName, double v) {
this.carId=i;
this.carName=carName;
this.carPrice=v;
}
}
|