maven exec:java run class file within jar

前端 未结 4 676
眼角桃花
眼角桃花 2020-12-31 19:00

I have my code packaged into a jar

The jar is packaged ok.

jar -tfv target/test-1.0-SNAPSHOT.jar

com/
com/codevalid/
com/codevalid/App.class
log4j.x         


        
4条回答
  •  梦谈多话
    2020-12-31 19:34

    You can run a jar file using the exec:java goal by adding some arguments:

    
        org.codehaus.mojo
        exec-maven-plugin
        1.3.2
        
            org.example.Main
            
                -jar
                target/myJar-1.0-SNAPSHOT.jar
            
        
    
    

    If you have an executable jar and don't want to define the entry point, you need to set the executable and use the exec:exec goal:

    
        org.codehaus.mojo
        exec-maven-plugin
        1.3.2
        
            java
            
                -jar
                target/myJar-1.0-SNAPSHOT.jar
            
        
    
    

提交回复
热议问题