1

I have two projects and projectB depends projectA. I use Maven to do it:

parent  
|- pom.xml  // I use <modules> here to add two projects in.  
|- MyProjectA  
|   `- pom.xml  
|- MyProjectB  
    `- pom.xml  

Now I can import projectA to projectB java code and use the classes in projectA. But when I try to use spring for prokectB as below:

<bean id="test" class="com.company.common.util.PropertyUtils"/>  // The class is inside projectA.

Spring says ClassNotFoundException.
Any ideads? Thanks.

user3093893
  • 119
  • 1
  • 9

1 Answers1

1

You can directly add projectA dependency into projectB pom.xml

    <dependency>
        <groupId>common.group</groupId>
        <artifactId>project-a-artifact</artifactId>
        <version>${project.version}</version>
    </dependency>

See also How can I create an executable JAR with dependencies using Maven? to check more possible solutions

Community
  • 1
  • 1
StanislavL
  • 56,971
  • 9
  • 68
  • 98