Maven does not add classpath to Eclipse project

前端 未结 7 2013
旧时难觅i
旧时难觅i 2020-12-15 03:37

I have a maven project, that I\'m working on Eclipse.

I use maven eclipse:eclipse to generate the classpath, but ... it NEVER adds the classpath on the eclipse proj

7条回答
  •  一向
    一向 (楼主)
    2020-12-15 04:32

    You need to add the extra source folders to the pom.xml with the build-helper-maven-plugin. Then run

    mvn eclipse:clean eclipse:eclipse

    For example this pom.xml ..

    
        4.0.0
    
        mygroup
        artifact
        1.0-SNAPSHOT
        jar
    
        artifact
        http://maven.apache.org
    
        
            UTF-8
        
    
        
            
                junit
                junit
                3.8.1
                test
            
        
    
        
            
                
                    org.codehaus.mojo
                    build-helper-maven-plugin
                    1.7
                    
                        
                            add-source
                            generate-sources
                            
                                add-source
                            
                            
                                
                                    client/src/main/java
                                
                            
                        
                        
                            add-resource
                            generate-resources
                            
                                add-resource
                            
                            
                                
                                    
                                        client/src/main/resources
                                        resources
                                    
                                
                            
                        
                    
                
            
        
    
    

    Generates this .classpath

    
      
      
      
      
      
      
      
    
    

    Make sure the folders exist, if the path is incorrect they wont be added. Look for this in the maven log.

    [INFO] skip non existing resourceDirectory /tmp/artifact/src/main/resources

    My team found the eclipse maven plugins to be unstable, opting to create our entire eclipse config through maven.

提交回复
热议问题