简体   繁体   中英

How to add a Maven dependency from a remote repository to my Java project?

Seriously guys? I cannot see why it should be that difficult!!!

I am coming from a C# background, so I am a newbie here.

My needs are simple, I am creating a new Java console application in Eclipse, I want to be able to use a library (in my case JSch) and I decided to use Maven.

After creating the project as a Java project, I right-clicked the project, and chose to convert it to Maven project and chose 'POM' rather than 'JAR' (was recommended in one of the stackoverflow answers).

Then I right-clicked the project again, chose Maven > Add dependency, found 'JSch' and added it.

Now what, I still cannot see any change in the project tree, no package is added and I cannot start using the added dependency in code.

All answers and forums are talking about something else, some are talking about using the command line or talking about creating Maven module projects which is not my interest.

Any help? What should I do next? where did the added dependent package go?

My recommendation would be to start with a new project and instead of creating Java project, create Maven project and move your sources to src/main/java , that would be a lot simpler than conversions, which are not working as one would expect...

Most important (and not intuitive) thing is to select "Create simple project" option.

新建Maven项目>创建一个简单项目(Eclipse)


You can specify, how to name the project in Eclipse in Advanced option, I'm using [name] (logically, you have to specify it)

在Eclipse中为Maven项目指定名称

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