更新时间:2023-11-18 15:45:34
你需要运行 Application.run()
因为这个方法启动整个Spring Framework。下面的代码将您的 main()
与Spring Boot集成。
You need to run Application.run()
because this method starts whole Spring Framework. Code below integrates your main()
with Spring Boot.
@Configuration
@ComponentScan
@EnableAutoConfiguration
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
ReconTool.java
ReconTool.java
@Component
public class ReconTool implements CommandLineRunner {
@Override
public void run(String... args) throws Exception {
main(args);
}
public static void main(String[] args) {
// Recon Logic
}
}
SpringApplication.run(ReconTool.class,args)
因为这样弹簧没有完全配置(没有组件扫描等)。只创建run()中定义的bean(ReconTool)。
SpringApplication.run(ReconTool.class, args)
Because this way spring is not fully configured (no component scan etc.). Only bean defined in run() is created (ReconTool).