From Maven, how do I run a class that lives under src/test/java?

前端 未结 4 1928
伪装坚强ぢ
伪装坚强ぢ 2020-12-30 18:36

I have inherited a codebase :)

Under src/test/java/ there\'s a file that I need to run (I need to run its public static void main(String[] args), not a

4条回答
  •  失恋的感觉
    2020-12-30 19:15

    Include following lines in pom.xml in exec-maven-plugin plugin. test

    plugin section in POM looks something like this

    
        org.codehaus.mojo
        exec-maven-plugin
        
            
                my-execution
                test
                
                    java
                
            
        
        
            com.example.MainClass
                test
        
    
    

    Note : com.example.MainClass is the class containing main method.

提交回复
热议问题