mybatis generator: Root class xxx cannot be loaded

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

mybatis generator: Root class xxx cannot be loaded

Byron Song
I'm using mybatis generator with maven.

But I got the error at maven generate:
[INFO] --- mybatis-generator-maven-plugin:1.3.1:generate (default-cli)
@ game_db ---
[WARNING] Root class net.cqjoy.db.model.EntityBase cannot be loaded,
checking for member overrides is disabled for this class
[WARNING] Existing file E:\workspace\server\trunk\game_db\src\main\java
\net\cqjoy\db\model\RoleExample.java was overwritten
[WARNING] Existing file E:\workspace\server\trunk\game_db\src\main\java
\net\cqjoy\db\model\Role.java was overwritten
[WARNING] Existing file E:\workspace\server\trunk\game_db\src\main\java
\net\cqjoy\db\dao\RoleMapper.java was overwritten

Here is my config:
                <javaModelGenerator targetPackage="net.cqjoy.db.model"
                        targetProject="src/main/java/">
                        <property name="enableSubPackages" value="true" />
                        <property name="trimStrings" value="true" />
                        <property name="rootClass" value="net.cqjoy.db.model.EntityBase"/>
                </javaModelGenerator>

In eclipse editor, I can directly link to the root class
net.cqjoy.db.model.EntityBase:
package net.cqjoy.db.model;

public abstract class EntityBase {

        protected Long id;

        public void setId(Long id) {
                this.id = id;
        }

        public Long getId() {
                return id;
        }
}


Why?
Reply | Threaded
Open this post in threaded view
|

Re: mybatis generator: Root class xxx cannot be loaded

Jeff Butler
Because your EntityBase class is not in the classpath of the generator
when it runs.

You need to add your EntityBase class to the classpath of the
generator.  To do this, you'll need to package your EntityBase in a
maven project (hopefully it is already there) - then add that project
as a dependency of the generator task.

Jeff Butler


On Sat, Dec 10, 2011 at 3:23 AM, Byron Song <[hidden email]> wrote:

> I'm using mybatis generator with maven.
>
> But I got the error at maven generate:
> [INFO] --- mybatis-generator-maven-plugin:1.3.1:generate (default-cli)
> @ game_db ---
> [WARNING] Root class net.cqjoy.db.model.EntityBase cannot be loaded,
> checking for member overrides is disabled for this class
> [WARNING] Existing file E:\workspace\server\trunk\game_db\src\main\java
> \net\cqjoy\db\model\RoleExample.java was overwritten
> [WARNING] Existing file E:\workspace\server\trunk\game_db\src\main\java
> \net\cqjoy\db\model\Role.java was overwritten
> [WARNING] Existing file E:\workspace\server\trunk\game_db\src\main\java
> \net\cqjoy\db\dao\RoleMapper.java was overwritten
>
> Here is my config:
>                <javaModelGenerator targetPackage="net.cqjoy.db.model"
>                        targetProject="src/main/java/">
>                        <property name="enableSubPackages" value="true" />
>                        <property name="trimStrings" value="true" />
>                        <property name="rootClass" value="net.cqjoy.db.model.EntityBase"/>
>                </javaModelGenerator>
>
> In eclipse editor, I can directly link to the root class
> net.cqjoy.db.model.EntityBase:
> package net.cqjoy.db.model;
>
> public abstract class EntityBase {
>
>        protected Long id;
>
>        public void setId(Long id) {
>                this.id = id;
>        }
>
>        public Long getId() {
>                return id;
>        }
> }
>
>
> Why?