When I’m trying to run my application I get an error:
java: variable userRepository not initialized in the default constructor
Here is the config file in which the problem occurs (as it turned out, the problem is with all the annotations that the constructors create)
@Configuration
@RequiredArgsConstructor
public class AppConfig {
private final UserRepository userRepository;
@Bean
public UserDetailsService userDetailsService() {
return email -> userRepository.findByEmail(email)
.orElseThrow(() -> new UsernameNotFoundException("User haven't found"));
}
...
UserRepository:
public interface UserRepository extends JpaRepository<User, Long> {
Optional<User> findByEmail(String email);
}
- “Enable annotation processing” is turning on
- already tried invalidate cashes
- tried reinstall lombok plugin
4
Try adding annotation processor path in your assembly file (as pom.xml) at
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>{maven.compile.plugin.version}</version>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
1