Entschuldigung, falls ich etwas falsch gemacht habe, dies ist das erste Mal, dass ich in einem Forum eine Frage stelle. Ich bin wirklich verloren.
Kannst du mir helfen? Vielen Dank im Voraus.
Klarstellungen:
Ich verwende maven 3.9.9 und jdk 23.0.1. Das Lombok-Plugin ist bereits installiert und MVN Clean Install hat die gleichen
Ausnahmen gestartet.
Das Ersetzen von @Data durch @Getter @Setter... funktioniert ebenfalls nicht. Ich dachte, das Problem könnte von Windows stammen, aber mein Freund sagte, dass der Fehler auch auf seinem Linux-Computer aufgetreten sei.
Beunruhigender ist, dass ich es für eine Sekunde geschafft habe, es zum Laufen zu bringen. Ich habe die Verwendung von Settern entfernt und einen benutzerdefinierten Konstruktor hinzugefügt. Als ich das entfernte und zu meinem ursprünglichen Code zurückkehrte, funktionierte es einmal mit „mvn exec:java“. Ich habe dann „mvn clean install“ versucht und es hat nicht mehr funktioniert. Ich verliere meinen Verstand.
Ich kann aus irgendeinem Grund keine weiteren Kommentare posten, also werde ich vorerst hier antworten, es sei denn, ich habe es geschafft, mehr zu posten.
Minimales reproduzierbares Beispiel:
pom.xml
Code: Select all
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
com.minimal_reproducible_example
stack_overflow_mre
1.0-SNAPSHOT
stack_overflow_mre
http://www.example.com
UTF-8
17
17
${project.groupId}.App
org.projectlombok
lombok
1.18.36
provided
Code: Select all
package com.minimal_reproducible_example;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor // No-argument constructor
@AllArgsConstructor // All-arguments constructor
public class Entity {
int id;
String name;
public String toString(){
return "[Entity n°"+this.id+" - "+this.name+"]";
}
}
Code: Select all
package com.minimal_reproducible_example;
public class App
{
public static void main( String[] args )
{
Entity entity1 = new Entity(4,"John");
System.out.println(entity1);
System.out.println(entity1.getId());
Entity entity2 = new Entity();
entity2.setId(4);
entity2.setName("john");
System.out.println(entity2);
}
}
Code: Select all
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.504 s
[INFO] Finished at: 2025-01-03T12:29:55+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.13.0:compile (default-compile) on project stack_overflow_mre: Compilation failure: Compilation failure:
[ERROR] /C:/Users/lucfo/SAE/stack_overflow_mre/src/main/java/com/minimal_reproducible_example/App.java:[8,26] constructor Entity in class com.minimal_reproducible_example.Entity cannot be applied to given types;
[ERROR] required: no arguments
[ERROR] found: int,java.lang.String
[ERROR] reason: actual and formal argument lists differ in length
[ERROR] /C:/Users/lucfo/SAE/stack_overflow_mre/src/main/java/com/minimal_reproducible_example/App.java:[10,35] cannot find symbol
[ERROR] symbol: method getId()
[ERROR] location: variable entity1 of type com.minimal_reproducible_example.Entity[ERROR] /C:/Users/lucfo/SAE/stack_overflow_mre/src/main/java/com/minimal_reproducible_example/App.java:[12,16] cannot find symbol
[ERROR] symbol: method setId(int)
[ERROR] location: variable entity2 of type com.minimal_reproducible_example.Entity[ERROR] /C:/Users/lucfo/SAE/stack_overflow_mre/src/main/java/com/minimal_reproducible_example/App.java:[13,16] cannot find symbol
[ERROR] symbol: method setName(java.lang.String)
[ERROR] location: variable entity2 of type com.minimal_reproducible_example.Entity[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.