user3093893
user3093893

Reputation: 129

Spring cannot find class which exists in classpath

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.

Upvotes: 1

Views: 854

Answers (1)

StanislavL
StanislavL

Reputation: 57381

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

Upvotes: 1

Related Questions