Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of quickly generating entity, dao and service by idea

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

The template code is also ready-made. You can guess and change it as needed. The template code is as follows: dao/mapper template:

# Common variables:## $YEAR-yyyy## $TIME-yyyy-MM-dd HH:mm:ss## $USER -Chen Zhicong # Available variables:## $class0-the context class Alias: $class## $class1-the selected class, like $class1, $class2## $ClassName-generate by the config of "ClassName", the generated class name#### Class Entry Structure:## $class0.className-the className # # $class0.packageName-the packageName## $class0.importList-the list of imported classes name## $class0.fields-the list of the class fields##-type: the field type##-name: the field name##-modifier: the field modifier Like "private", or "@ Setter private" if include annotations## $class0.allFields-the list of the class fields include all fields of superclass##-type: the field type##-name: the field name##-modifier: the field modifier, like "private", or "@ Setter private" if include annotations## $class0.methods-the list of class methods##-name: the method name##-modifier: the method modifier Like "private static" # #-returnType: the method returnType##-params: the method params, like "(String name)" # # $class0.allMethods-the list of class methods include all methods of superclass##-name: the method name##-modifier: the method modifier, like "private static" # #-returnType: the method returnType##-params: the method params Like "(String name)" # package $class0.PackageName Import com.mapper.GeneralMapper;/** @ author chenzhicong * @ version $Id: ${ClassName} .java, v 0.1$ TIME $USER Exp $$* / public interface $ClassName extends GeneralMapper {}

Service, serviceImpl operation methods are similar, do not repeat, according to the above method to establish the template on the line.

After the template is established, we just need to press the shortcut key Alt+Insert (or right-Generate) in the newly generated entity class-select the corresponding template-and then select the generate directory:

It seems that it can only be generated in the same directory in entity, and we cannot choose another directory. We need to move to the corresponding package. The generated dao is shown in the figure:

Summary

At this point, the code is generated, this method has exposed itself to the groovy script for the first time, but it still doesn't know how to use it, but it can also be changed by copying and pasting other people's scripts. Let's do this first, and then Baidu will encounter problems related to the script later.

Thank you for your reading, the above is "idea quickly generate entity, dao, service method" content, after the study of this article, I believe you on the idea rapid generation of entity, dao, service method this problem has a deeper understanding, the specific use of the need for you to practice and verify. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report