0

Previously I had only one project named "projectA". I have a XML bean configuration file "service.xml" in "projectA" with bean of class "com.home.karoom.impl.adapter"

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
           http://www.springframework.org/schema/aop
           http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context-2.5.xsd">

<bean id="<bean id="espAdapter" class="com.home.karoom.impl.adapter"> 
<property name="writer" ref="writer" />
</bean>
</beans>

Now, I created new project called "projectB" and moved the bean-class "com.home.karoom.impl.adapter" to "projectB".

Now, the bean-class "com.home.karoom.impl.adapter" doesn't exist anymore in "projectA"

How ca I refer to the new class location in "projectB" using "service.xml" ?

watchme
  • 720
  • 1
  • 9
  • 25
R.Almoued
  • 219
  • 6
  • 16
  • Are you using an IDE to compile? –  Feb 22 '18 at 12:47
  • @EugenCovaci yes I do – R.Almoued Feb 22 '18 at 12:53
  • Hmm, spring 2.5 is now rather old and you should considere an upgrade. Anyway, the xml file is processed at run time so the class `com.home.karoom.impl.adapter` **must** exist somewhere in runtime classpath. The common way is that it exists in the project, eventually though a library jar. – Serge Ballesta Feb 22 '18 at 12:56

2 Answers2

0

I think you have to import the file into your project

<import resource="classpath:spring-config.xml" />
0

here is a good explanation on how to share code/class between projects.

Short answer is, your class com.home.karoom.impl.adapter should be put in separate project and package as a jar. Then added as dependency to your projects (A and B).

Be sure to follow convention and name your classes starting with capital letter

Bolat
  • 1
  • 1