3
我使用springboot 1.3.8和我有一個帶參數的構造函數@Autowired
但我得到的錯誤:沒有發現默認的構造函數...Springboot使用構造上與@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);
}
}
答案在你的消息。沒有默認構造函數,即公共App(){...}可用。你爲什麼不在域上使用@Autowired? – lrother
CLIhelper是一個bean嗎? –
是的,CLIhelper是一個bean,它被命名爲@Component –