简体   繁体   中英

Eclipse M2E / change Order and Export

I'm working with maven projects in Eclipse (Indigo).

In order to compile some classes that need endorsed libraries (webservices-api.jar) I go to "Properties/Java Build Path/Order and Export" and move "Maven Dependecies" before "JRE System Library".

The problem is that whenever I click on the "Maven/Update Project configuration" option the entries are rearranged and "JRE System Library" is always the first entry, and the code no longer compiles.

Is there a way to have M2E remember my choice and stop rearranging the libraries?

Thanks in advance

I understand the webservices-api.jar overrides some classes in standard JRE, right?

The only way out I see is moving the jar to JRE\\lib\\ext and mark this dependency in Maven as system . It's not a good solution, as Maven will stop packing this artifact into your target and it will be your responsibility to handle it. This has a chance to work — but please note I haven't tried it, so I'm not sure if you manage to override your JRE libs correctly.

As for m2e, it takes over control over your Eclipse project settings, so manual tweaking is good as long as you don't update configuration.

The solution I ended up implementing is having an ant target do a replacement in the .classpath file to swap the classpath containers. I add an ant builder to my project that calls that target and then refresh the project before the java compiler. A little complex, but it works like a charm.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM