1

I have created 2 dummy projects by start.spring.io (Maven, Java):

  1. com.example.lion
  2. com.example.zoo

I want to import lion project to zoo project as dependency.

So I go to lion folder and execute:

mvn clean install mvn install:install-file -Dfile=target/lion-0.0.1-SNAPSHOT.pom -DpomFile=pom.xml 

Then I add dependency to zoo pom.xml:

<dependency> <groupId>com.example</groupId> <artifactId>lion</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency> 

After that I execute mvn clean install in zoo folder.

I never got errors in console.

So now if I go to any class in zoo project, and import:

import com.example.lion.*; 

Then mvn clean install, I get error:

package com.example.lion does not exist

In my IntelliJ IDEA I can see, that lion dependency is in External Libraries and maven-tool, but why I can not access that from code?

12
  • Does the maven project com.example.lion actually have a java package in com.example.lion? By this i mean does your src directory for the lion project have the children main/java/com/example/lion? Commented Apr 9, 2019 at 13:38
  • Additionally the maven install line reads like you are putting a pom-file into the repo and not the jar file. Commented Apr 9, 2019 at 13:42
  • Because if that directory doesn't exist then there would not be a package called com.example.lion to import in the zoo project. Commented Apr 9, 2019 at 13:46
  • You don't have to and should not perform mvn install:install-file ... explicitely in addition to mvn install! The install phase (invoked with the former executed) has the Install Plugin's install goal bound to it by default which does this automatically for you, by using the project's POM declarations of the Maven Coordinates <groupId>, <artifactId>, <version> (GAV). Commented Apr 9, 2019 at 13:59
  • cheemcheem: yes it exists. start.spring.io create all structure automatically DrHopfen: what would be correct install line? Gerold Broser: i tried only with mvn install now, but the problem is not solved Commented Apr 9, 2019 at 14:01

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.