Ich verwende springboot 1.3.8 und ich habe ein @Autowired
auf einem Konstruktor mit Parametern aber ich habe den Fehler: Kein Standardkonstruktors gefunden ...Springboot Verwendung auf Konstruktor mit Parametern @Autowired
@SpringBootApplication
public class App implements CommandLineRunner {
private ApplicationContext context;
private CLIHelper cliHelper;
@Autowired
public App(ApplicationContext context, CLIHelper cliHelper) {
this.context = context;
this.cliHelper = cliHelper;
}
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
}
Die Antwort ist in Ihrer Nachricht. Kein Standardkonstruktor, d. H. Öffentliche App() {...} verfügbar. Warum verwenden Sie nicht @Autowired für Felder? – lrother
Ist CLIhelper eine Bohne? –
Ja, CLIHelp ist eine Bean, sie ist als @Component –