Consider the following dependency hierarchy:
Now I have maven-jibx-plugin
in project D
which generates the compiled classes in target/classes
folder. But when I run my spring-boot
project A
the generated classes from project D
could not be resolved. Resolve dependencies from workspace is also checked from maven preferences of project A
To me it looks like Eclipse and Maven do not recognize project D as a related project.
There are two possible solutions:
In Eclipse you can add project D as a dependent project to project A's build path. Go to the project's Properties dialog. Select Java Build Path and then switch to the Projects tab. There you should add project D.
Or alternatively you rely on Maven's dependency management. Therefore you have to add a dependency to project A's POM file. First add a <dependency>
( if not already done ) to the <dependencies>
section. Now comes the important part! Maven can only resolve this dependency if you have installed the compiled maven artifact ( the jar file ) in your local maven repository. On the shell switch into project D's directory and then run mvn install
I hope that did the trick.
Have you tried adding generated sources folder as a source folder in eclipse? You can do this from eclipse (right click the generated sources or any folder in it > Build Path > Use as Source Folder) or you can use maven build helper plugin by adding something like below to your pom.xml
<!-- MAVEN ADD GENERATED-SOURCES TO CLASSPATH -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>${maven.plugin.build-helper.version}</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>target/generated-sources/annotations</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
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.