Eclipse M2E / change Order and Export

▼魔方 西西 提交于 2019-12-12 11:50:40

问题


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


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/7810346/eclipse-m2e-change-order-and-export

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!