0

I'm trying to learn Spring at the moment. In nearly every spring tutorial, you start with a project, that has a "spring-starter" project as parent. However, until now I used the parent to define some common dependencies (like junit or yodatime) and plugins (like maven-compiler-plugin) that all my projects should have. I took that common-project as a parent for most of my projects. Now I can't do that, because the role of the parent is occupied by the spring project. I could define the common dependencies and plugins in this project again, but then it seems to be easy to have different verisions and all in all it looks a lot like bad code.

My question now is, is there a way to define a "set" of dependencies and/or plugins and import them into a project without having a parent?

tomtomssi
  • 1,017
  • 5
  • 20
  • 33
Urr4
  • 611
  • 9
  • 26

2 Answers2

1

Normally, what I do in Eclipse is create a general project. After it is created, I do a right click on my project and press Configure -> Convert to maven project. I assume there will be an equivalent way of doing this in Spring.

Another alternative (again in eclipse, sorry if it is different in spring, but it should have an equivalent) is creating a simple maven project:

 New project -> Maven project -> 
 Check on "Create a simple project (skip archetype selection) -> 
 Next -> Enter your artifact group ID and artifact ID and click finish.     

That should do the trick even without selecting a parent application.

I prefer the first alternative, since everything is already filled in for me, but both of them do the same thing.

randombee
  • 699
  • 1
  • 5
  • 26
  • I'm not sure if we are talking about the same thing :) I use eclipse with maven, but I'm trying to learn the Spring Boot Framework (it's a JavaEE alternative). In most tutorials for Spring Boot, they get their dependencies by using a predefined Parent project, so I can't define an own parent to obtain a set of dependencies I defined myself. Basically I have two "packages" containing many dependencies and I'm looking for an easy way to get both of them into a new project. – Urr4 Mar 08 '16 at 09:52
  • But you can add your dependencies later on your pom.xml file. You just need to know what group/artifact id you set for those packages and add them later. Sorry maybe I'm misunderstanding you :) Do you have a pom file for each of those packages? If you do, they will contain a "main" group id and artifact id, and if you include that in the new pom, it should work – randombee Mar 08 '16 at 11:07
  • I really think we don't get each other :) Lets say I have a project A, having dependencies D1, D2, D3 and a Project B, having Dependencies D4, D5 and D6. I now want to create a new project C, having Dependencies D1, D2, D3, D4, D5 and D6, but i don't want to import them all by hand (because in reality, there are like 50 dependencies each). If i wanted to tell maven "Import every dependency from project A", i would make project A the parent of project C. But i want to tell maven "Import every dependency from project A AND project B", but I can't make A and B the parent. – Urr4 Mar 11 '16 at 12:00
  • But if projects A and B have their own pom, all you have to do is (without setting any parent) create project C and import A and B as dependencies. This will resolve the rest of the dependencies automatically :) – randombee Mar 12 '16 at 23:21
  • Only if you import them with type "pom", but you're right. – Urr4 Mar 14 '16 at 20:34
0

I didn't have the chance to try it out, but it seems, that the answer of Guillaume Darmont in How to use POMs as a dependency in Maven? is exactly the solution to my problem.

Maybe this was what you (randombee) were trying to tell me, but I didn't quite get it :)

Community
  • 1
  • 1
Urr4
  • 611
  • 9
  • 26
  • That's exactly what I was trying to explain but I didn't say it clear enough I guess... hope it solves your problem anyway :) – randombee Mar 15 '16 at 13:23