Mybatis, referencing a class from another project in the Mapper.xml

0

Good morning, I am using MyBatis and I am having a ClassNotFound error in a resultMap in which I have a class from another project referenced. I attach code below:

- Mapper.xml : Here I will only place the resultMap, which is where I am having problems being the place where I define the external project class.

    <resultMap id="BaseResultMapGeneralConfig" type="classpath:com.iecisa.tecdoc.sirene.common.types.GeneralConfig">
    <id column="id" jdbcType="NUMERIC" property="id" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="value" jdbcType="VARCHAR" property="value" />
    <result column="type" jdbcType="NUMERIC" property="type" />
  </resultMap>

In theory, as far as I know, that would be more than enough. Now, I have also added in my main project, the project of which I want to refer to the class in the Projects tab of the Java Build Path of my main project, and also I have checked the external project check in Order and Export .

- The trace error:

Struts has detected an unhandled exception:

Messages:   
Cannot find class: classpath:com.iecisa.tecdoc.sirene.common.types.GeneralConfig
Could not resolve type alias 'classpath:com.iecisa.tecdoc.sirene.common.types.GeneralConfig'. Cause: java.lang.ClassNotFoundException: Cannot find class: classpath:com.iecisa.tecdoc.sirene.common.types.GeneralConfig
Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'classpath:com.iecisa.tecdoc.sirene.common.types.GeneralConfig'. Cause: java.lang.ClassNotFoundException: Cannot find class: classpath:com.iecisa.tecdoc.sirene.common.types.GeneralConfig
Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'classpath:com.iecisa.tecdoc.sirene.common.types.GeneralConfig'. Cause: java.lang.ClassNotFoundException: Cannot find class: classpath:com.iecisa.tecdoc.sirene.common.types.GeneralConfig
Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'classpath:com.iecisa.tecdoc.sirene.common.types.GeneralConfig'. Cause: java.lang.ClassNotFoundException: Cannot find class: classpath:com.iecisa.tecdoc.sirene.common.types.GeneralConfig
### Error building SqlSession. ### The error may exist in com/iecisa/tecdoc/sirene/db/map/SireneConfigMapper.xml ### The error occurred while processing mapper_resultMap[BaseResultMapGeneralConfig] ### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'classpath:com.iecisa.tecdoc.sirene.common.types.GeneralConfig'. Cause: java.lang.ClassNotFoundException: Cannot find class: classpath:com.iecisa.tecdoc.sirene.common.types.GeneralConfig
Error inicializando SqlSession. Causa: org.apache.ibatis.exceptions.PersistenceException: ### Error building SqlSession. ### The error may exist in com/iecisa/tecdoc/sirene/db/map/SireneConfigMapper.xml ### The error occurred while processing mapper_resultMap[BaseResultMapGeneralConfig] ### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'classpath:com.iecisa.tecdoc.sirene.common.types.GeneralConfig'. Cause: java.lang.ClassNotFoundException: Cannot find class: classpath:com.iecisa.tecdoc.sirene.common.types.GeneralConfig
Error creando SqlSession: java.lang.RuntimeException: Error inicializando SqlSession. Causa: org.apache.ibatis.exceptions.PersistenceException: ### Error building SqlSession. ### The error may exist in com/iecisa/tecdoc/sirene/db/map/SireneConfigMapper.xml ### The error occurred while processing mapper_resultMap[BaseResultMapGeneralConfig] ### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'classpath:com.iecisa.tecdoc.sirene.common.types.GeneralConfig'. Cause: java.lang.ClassNotFoundException: Cannot find class: classpath:com.iecisa.tecdoc.sirene.common.types.GeneralConfig

I have tried different ways, as well as putting the class without "classpath:", but I can not find a way to solve the problem.
Any ideas? Have I overlooked something?
All help is appreciated. Greetings.

    
asked by M.Gea 20.09.2017 в 10:19
source

1 answer

0

I have solved the error. The problem was that my main project is Maven and the external one is not. In the end I just had to add it as .jar, add it to pom.xml and compile. With that the error was solved to me!

    
answered by 20.09.2017 / 17:08
source