Unit test using the Reflections google library fails only when executed by Maven

前端 未结 5 1217
有刺的猬
有刺的猬 2020-12-18 00:00

I am using the Google Reflections library for querying certain resources in the classpath. Those resources are located in the same location than the classes in my project.

5条回答
  •  清酒与你
    2020-12-18 00:10

    I just encountered the same problem with Reflections library (version 0.9.11), only when executing unit tests from Maven builds. The link provided in the accepted answer pointed me in the right direction.

    A simple POM file change to my Surefire plugin fixed this:

                
                org.apache.maven.plugins
                maven-surefire-plugin
                2.21.0
                
                    false
                
            
            
                maven-failsafe-plugin
                2.21.0
                
                    false
                
                
                    
                        
                            integration-test
                            verify
                        
                    
                
            
    

    The config parameter defaults to 'true'. Forcing it to 'false' seems to resolve the classloader problem in my unit tests.

提交回复
热议问题