title: Build jar and run spring boot from cmd
body: <p>I'm new to springboot and using springboot 2 version.</p>
  <p>I would like to run my spring boot application using : <strong>java -jar my-app-0.0.1-SNAPSHOT.jar</strong> from the command prompt.</p>
  <p>However, when i build the application using eclipse it calls myService.getMyMethod() directly and does not build the jar.</p>
  <p>I want to build the jar file first and then run <strong>java -jar my-app-0.0.1-SNAPSHOT.jar</strong> from the command prompt which will invoke myService.getMyMethod()</p>
  <p>I already have spring-boot-maven-plugin in pom.xml, running <strong>mvn package</strong> / <strong>mvn install</strong> starts the application but not generating the jar file in the target folder. mvn clean package also not working, MyApplication  is using implements CommandLineRunner and starts invoking the method on build, hence not generating the build jar file</p>
  <p>My main class:</p>
  <pre><code>@SpringBootApplication
  public class MyApplication implements CommandLineRunner {
  
  private static String URL = &quot;ws://localhost:8080/spring-mvc-java/chat&quot;;
  
     @Autowired
     private MyService myService;
  
     public static void main(String[] args) {
         SpringApplication.run(MyApplication.class, args);
     }
     @Override
     public void run(String... args) throws Exception {
         myService.getMyMethod(URL);
     }
  }
  
  </code></pre>
  <p>My service class:</p>
  <pre><code>@Service
  public class MyServiceImpl implements MyService {
  
       public void getMyMethod(String URL){
             WebSocketClient client = new StandardWebSocketClient();
             WebSocketStompClient stompClient = new WebSocketStompClient(client);
             stompClient.setMessageConverter(new MappingJackson2MessageConverter());
             StompSessionHandler sessionHandler = new MyStompSessionHandler();
             stompClient.connect(URL, sessionHandler);
             new Scanner(System.in).nextLine(); // Don't close immediately.
             }
  }
  </code></pre>