I'm following the Spring Boot CommandLineRunner : filter option argument for creating CommandLineRunner for my SpringBoot application. What I dont understand is how can I run this specific command in ma app? In this specific example there is a FileProcessingCommandLine class with 'run' method implemented. Now how can I run this from command prompt?
            Asked
            
        
        
            Active
            
        
            Viewed 1,329 times
        
    1 Answers
0
            a think that cannot be run manually. Spring framework is responsible for running this method!.
You should  mark your class with Spring’s @Component annotation so that will automatically picked up by @SpringBootApplication.
If your class implements Spring Boot’s CommandLineRunner it will run after all the beans are created and registered. 
@Component
public class FirstCommandLineRunner implements CommandLineRunner {
    @Override
    public void run(String... strings) throws Exception {
        System.out.println("hello world");
    }
}
 
    
    
        Nikolay Rusev
        
- 4,060
- 3
- 19
- 29
- 
                    I see, it's probably my missunderstanding. I'm trying to find a way how to run some command manualy from console that can see all spring environment for purposes like 'data import', some maintenance tasks etc. – David Marko Sep 24 '15 at 08:41
- 
                    if you want to check the health of the app you can check this http://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html it is perfect for maintenance. For data import you can use `CommandLineRunner`, when app is loaded - do initial data import. – Nikolay Rusev Sep 24 '15 at 08:49
 
    