IntelliJ IDEA 13 debugger don't stop on breakpoint in java for maven project

后端 未结 3 1986
野趣味
野趣味 2021-02-02 12:58

I have a breakpoint on a line where is the System.out.println(\"test\") command. I believe that the command is reached by execution because I see the printed string

3条回答
  •  野的像风
    2021-02-02 13:42

    To debug web applications in maven projects using the Intellij Community Edition, you can add a tomcat or jetty plugin to your WAR pom like this:

    
        
            
                org.apache.tomcat.maven
                tomcat7-maven-plugin
                
                    8080
                    /yourapp
                
            
            
                org.mortbay.jetty
                maven-jetty-plugin
            
        
    
    

    It's possible if needed to add database drivers like this:

    
        org.mortbay.jetty
        maven-jetty-plugin
        
            
               ... your database driver groupId and artifactId ...
            
        
    
    

    Then using these plugins the application can be started in the command line (from the pom directory):

    mvnDebug clean install tomcat7:run-war
    

    Or for jetty:

    mvnDebug clean install jetty:run-war
    

    With the application running in debug mode from the command line (you don't need to run it from Intellij), do a remote debugging configuration similar to what you posted and the breakpoint should be hit.

    If you use Intellij Ultimate Edition then this is not necessary, because you can create a server configuration for Tomcat or any other server and deploy the application in a fully integrated way, with debugging and hot deployment handled transparently.

    There is a 30 day trial where you can evaluate this feature and others.

提交回复
热议问题