java.lang.IllegalArgumentException: already added: Lorg/hamcrest/BaseDescription; Conversion to Dalvik format failed with error 1

前端 未结 3 726
难免孤独
难免孤独 2021-01-04 11:13

First of all, there are at least 2 postings with the same problem but these solutions don\'t work anymore, at least not in my installation.

I\'m using m2e with Eclip

3条回答
  •  天涯浪人
    2021-01-04 11:28

    Unfortunately Eclipse does not understand the maven test scope. It pulls hamcrest classes into the build with JUnit 4.10. Use JUnit 4.8.1 or, if you really need to use 4.10+ version of JUnit, you can use a maven profile without the junit dep in eclipse.

    1. Include the JUnit dep in the default profile and create an empty 'no-junit' profile (see example pom below)
    2. Eclipse project properties > Maven > Active Maven Profiles: no-junit
    3. Manually add the junit library to the eclipse Build path of your project

    Here is the relevant part of the pom.xml:

    
        
            default
            
                true
            
            
                
                    junit
                    junit
                    4.10
                    test
                
            
        
        
            no-junit
        
    
    

提交回复
热议问题