I downloaded the following project and imported it into Visual Studio Code
:
https://github.com/oktadeveloper/okta-spring-boot-2-angular-5-example
I have a problem on the following class, when invoking: car.getName()
.
which content is:
CoolCarController.java
package com.okta.developer.demo;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Collection;
import java.util.stream.Collectors;
@RestController
class CoolCarController {
private CarRepository repository;
public CoolCarController(CarRepository repository) {
this.repository = repository;
}
@GetMapping("/cool-cars")
@CrossOrigin(origins = "http://localhost:4200")
public Collection<Car> coolCars() {
return repository.findAll().stream()
.filter(this::isCool)
.collect(Collectors.toList());
}
private boolean isCool(Car car) {
return !car.getName().equals("AMC Gremlin") &&
!car.getName().equals("Triumph Stag") &&
!car.getName().equals("Ford Pinto") &&
!car.getName().equals("Yugo GV");
}
}
here is also the content of:
Car.java
package com.okta.developer.demo;
import lombok.*;
import javax.persistence.Id;
import javax.persistence.GeneratedValue;
import javax.persistence.Entity;
@Entity
@Getter @Setter
@NoArgsConstructor
@ToString @EqualsAndHashCode
public class Car {
@Id @GeneratedValue
private Long id;
private @NonNull String name;
}
As you can see on the image below, I'm getting the error:
[Java] The method getName() is undefined for the type Car
I think Visual Studio Code
doesn't understand the package: lombok
.
Any idea on how can I make Visual Studio Code
understand that package?
Thanks!
Ok, Installing extension: Lombok Annotations Support for VS Code
(gabrielbb.vscode-lombok) did the trick.