Witam
Mam straszny problem z wstrzyknięciem zależnosci , chodzi o to że kończy się ona null pointer exception
Posiadam interface
package com.example.demo;
public interface inter {
public void sout();
}
Oraz jego implementację (tutaj akurar @Component ) ale nawet gdy mam @Service jest to samo
package com.example.demo;
import org.springframework.stereotype.Component;
@Component
public class interImpl implements inter {
@Override
public void sout() {
System.out.println("Udało Się");
}
}
Oraz klasę w której chcę dodać dependency
package com.example.demo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class DemoApplication {
@Autowired
static interImpl inter;
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
inter.sout();
}
}
I odpalenie takiego kodu kończy się :
Exception in thread "main" java.lang.NullPointerException
Po odpaleniu tego kodu w debagerze okazuje się ze obiekt inter jest pusty. Szukam od dłuższego czasu odp dlaczego tak się dzieje ale nie mogę znaleźć
https://zapodaj.net/499ebb902b4f8.png.html
Link do projektu :
http://hostuje.net/file.php?id=9520baf3355db04f66da7976ac44d841