How to stop mybatis generator to overwrite DAO and MAP file.

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to stop mybatis generator to overwrite DAO and MAP file.

Li ZW
Hi:
I have a maven web project and now i try to export it as war.
But when i export it, the mybatis generator will run and overwrite my DAO and MAP file.



// below is one of my DAO
public interface UserMapper {
   
int deleteByPrimaryKey(Integer id);


   
int insert(User record);


   
int insertSelective(User record);


   
User selectByPrimaryKey(Integer id);


   
int updateByPrimaryKeySelective(User record);


   
int updateByPrimaryKey(User record);


   
//I add two methods in this object, and add corresponding sql statement in map file
   
List<User> selectAllUser();


   
List<User> selectUserByQuery(User record);
}




Every time i export project, the file will be overwrited, and two methods are delete.

Does anyone have idea about it?  I am new to Mybatis. Thanks.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to stop mybatis generator to overwrite DAO and MAP file.

Jeff Butler
It sounds like you have Maven configured to automatically execute the generator (did you configure an <execution>?).  This is probably not what you want since you are modifying the generated code.  In your case it would be better to execute the generator manually and only when you want to regenerate the code.

It also sounds like you have the generator configured so that it will overwrite files - which is not the default.

If you need more help, please post the relevant parts of your pom.xml file.

Jeff Butler


On Wed, Jul 27, 2016 at 8:32 AM Li ZW <[hidden email]> wrote:
Hi:
I have a maven web project and now i try to export it as war.
But when i export it, the mybatis generator will run and overwrite my DAO and MAP file.



// below is one of my DAO
public interface UserMapper {
   
int deleteByPrimaryKey(Integer id);


   
int insert(User record);


   
int insertSelective(User record);


   
User selectByPrimaryKey(Integer id);


   
int updateByPrimaryKeySelective(User record);


   
int updateByPrimaryKey(User record);


   
//I add two methods in this object, and add corresponding sql statement in map file
   
List<User> selectAllUser();


   
List<User> selectUserByQuery(User record);
}




Every time i export project, the file will be overwrited, and two methods are delete.

Does anyone have idea about it?  I am new to Mybatis. Thanks.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to stop mybatis generator to overwrite DAO and MAP file.

Li ZW
In reply to this post by Li ZW
It's part of my pom.xml. And MBG settings are below

<plugins>
     
<plugin>
       
<groupId>org.mybatis.generator</groupId>
       
<artifactId>mybatis-generator-maven-plugin</artifactId>
       
<version>1.3.2</version>
       
<executions>
         
<execution>
           
<id>Generate MyBatis Artifacts</id>
           
<goals>
             
<goal>generate</goal>
           
</goals>
         
</execution>
       
</executions>
       
<configuration>
         
<verbose>true</verbose>
         
<overwrite>true</overwrite>
       
</configuration>
     
</plugin>
   
</plugins>


At last, i delete this part before exporting project, and it does work. My changes in DAO file and  map xml are not overwrited.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Loading...