In Maven, my dependencies are set up but I get a ClassNotFoundException when I run generated jar

后端 未结 2 1716
闹比i
闹比i 2020-12-22 06:29

I was following along with the maven tutorial at http://www.youtube.com/watch?v=IRKu8_l5YiQ.

I created a maven project with the default archetype. Then I added the

2条回答
  •  一向
    一向 (楼主)
    2020-12-22 07:30

    When I first started using Maven, I had to provide some additional build "plugin"/"configuration" in order for the Jar to be built with the correct manifest file, including the class-path entry and the dependent jars included with the jar...

    
        
            
                maven-jar-plugin
                2.4
                
                    
                        
                            true
                            
                            
                            
                            lib/
                            
                        
                    
                
                    
            
                org.apache.maven.plugins
                maven-dependency-plugin
                2.1
                
                    
                        copy-dependencies
                        package
                        
                            copy-dependencies
                        
                        
                            ${project.build.directory}/lib
                            false
                            false
                            true
                        
                    
                
            
         
          org.apache.maven.plugins
          maven-compiler-plugin
          2.3.2
          
           
           
          
         
        
    
    

    You might want to do some additional reading on some the flags/plugins. This is nearly a year old, so some may have been deprecated...

提交回复
热议问题