简体   繁体   English

Maven:在Eclipse的构建路径中使用列出的依赖项吗?

[英]Maven: Using listed dependency in build path in Eclipse?

I am new to Maven, and as I added a dependancy in my pom.xml, the dependency got resolved and gets packaged in target/dependencies. 我是Maven的新手,当我在pom.xml中添加依赖项时,该依赖项已解决,并打包在目标/依赖项中。

However I do not know how to use them in Eclipse. 但是我不知道如何在Eclipse中使用它们。

It is not in the project's java build path in Eclipse, and even though I can circumvent this in various ways (eg manually add the dependencies from the local repo to build path in eclipse), there should be a proper way to manage your dependencies in maven and for Eclipse to be able to "see" the dependencies. 它不在Eclipse中项目的Java构建路径中,即使我可以通过各种方式来绕开它(例如,手动从本地存储库添加依赖项以在Eclipse中构建路径),也应该有一种适当的方法来管理Eclipse中的依赖项Maven和Eclipse能够“看到”依赖关系。 I want to add the dependencies on one place (pom.xml) and both maven and eclipse to able to understand that and add them to build path/classpath. 我想将依赖项添加到一个地方(pom.xml)并同时将maven和eclipse都理解为能够将其理解,并将它们添加到构建路径/类路径中。

How is this done? 怎么做? Via plugin? 通过插件? Which plugin should I use? 我应该使用哪个插件?

I assume you are using the command line Maven option instead of the eclipse plugin. 我假设您使用的是命令行Maven选项而不是eclipse插件。

if that is the case, then once you have added dependency and did a "mvn install", you need to do "mvn eclipse:eclipse". 如果是这种情况,那么一旦添加了依赖性并执行了“ mvn安装”,就需要执行“ mvn eclipse:eclipse”。

Every time you add a dependency and install, you will have to do a eclipse:eclipse else it will not put the new jars in classpath. 每次添加依赖项并安装时,都必须执行eclipse:eclipse,否则它将不会将新的jar放入classpath中。

Alternatively, switch to m2eclipse 或者,切换到m2eclipse

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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