关键词:
Intellij IDEA 2018.1.2版本
CodeGenerator插件地址:https://github.com/lotabout/CodeGenerator/releases
步骤一:安装插件
下载CodeGenerator.jar到本地磁盘,打开Intellij安装插件的界面进行安装
步骤二:添加Builder模式的模板
## Tutorial for writing your templates ## ## 1. First you need to know basic syntax of velocity[1]. ## 2. Then it is necessary to understand the variable that CodeGenerator provides ## and its inner structure for retrieving the information you need for generating code. ## 3. Learn to use the utils provided so that you can ask for further information ## or reduce your workload. ## ## Variables Provided (Class Mode) ## ------------------------------- ## Class mode means you want to create new classes(file). ## ## - ClassName: String The name spcified by `Target Class Name` ## - PackageName: String The package name specified by `Target Class Name` ## - class0: ClassEntry The class that the action is triggered upon ## - raw: PsiClass ## - String packageName ## - importList: List<String> ## - fields: List<FieldEntry> ## - allFields: List<FieldEntry> ## - methods: List<MethodEntry> ## - allMethods: List<MethodEntry> ## - innerClasses: List<ClassEntry> ## - allInnerClasses: List<ClassEntry> ## - typeParamList: List<String> ## - name: String ## - superName: String ## - superQualifiedName: String ## - qualifiedName: String ## - typeParams: int ## - hasSuper: boolean ## - deprecated: boolean ## - enum: boolean ## - exception: boolean ## - abstract: boolean ## - implementNames: String[] ## - isImplements(String): bool ## - isExtends(String): bool ## - matchName(String): bool ## ## - class1: ClassEntry The first selected class, where `1` is the postfix ## you specify in pipeline ## ... ## ## - MemberEntry (FieldEntry/MethodEntry common properties) ## - raw: PsiField(for field), PsiMethod(for method) ## - name: String ## - accessor: String ## - array: boolean ## - nestedArray: boolean ## - collection: boolean ## - map: boolean ## - primitive: boolean ## - string: boolean ## - primitiveArray: boolean ## - objectArray: boolean ## - numeric: boolean ## - object: boolean ## - date: boolean ## - set: boolean ## - list: boolean ## - stringArray: boolean ## - calendar: boolean ## - typeName: String ## - typeQualifiedName: String ## - type: String ## - boolean: boolean ## - long: boolean ## - float: boolean ## - double: boolean ## - void: boolean ## - notNull: boolean ## - char: boolean ## - byte: boolean ## - short: boolean ## - modifierStatic: boolean ## - modifierPublic: boolean ## - modifierProtected: boolean ## - modifierPackageLocal: boolean ## - modifierPrivate: boolean ## - modifierFinal: boolean ## ## - FieldEntry ## - constant: boolean ## - modifierTransient: boolean ## - modifierVolatile: boolean ## - enum: boolean ## - matchName(String): bool ## ## - MethodEntry ## - methodName: String ## - fieldName: String ## - modifierAbstract: boolean ## - modifierSynchronzied: boolean ## - modifierSynchronized: boolean ## - returnTypeVoid: boolean ## - getter: boolean ## - deprecated: boolean ## - matchName(String): bool ## ## Variables for Body Mode ## ----------------------- ## - class0: ClassEntry The current class ## - fields: List<FieldEntry> All selected fields ## - methods: List<MethodEntry> All selected methods ## - members: List<MemberEntry> selected fields+methods ## - parentMethod: MethodEntry The nearest method that surround the current cursor ## ## Utilities ## --------- ## - settings: CodeStyleSettings settings of code style ## - project: Project The project instance, normally used by Psi related utilities ## - helper: GenerationHelper ## - StringUtil: Class ## - NameUtil: Class ## - PsiShortNamesCache: Class utility to search classes ## - PsiJavaPsiFacade: Class Java specific utility to search classes ## - GlobalSearchScope: Class class to create search scopes, used by above utilities ## - EntryFactory: Class EntryFactory.of(...) to turn PsiXXX to XXXEntry. ## ## Other feature ## ------------- ## - Auto import. If the generated code contains full qualified name, Code Generator will try to ## import the packages automatically and shorten the name. ## For example `java.util.List<>` -> `List<>` ## ## References ## ---------- ## - Velocity syntax: http://velocity.apache.org/engine/1.7/user-guide.html public static class Builder private $class0.name instance = new $class0.name(); private Builder() public static Builder getInstance() return new Builder(); public static Builder getInstance($class0.name instance) Builder builder = new Builder(); builder.instance = instance; return builder; #if ( $members.size() > 0 ) #foreach( $member in $members ) #set($name = $StringUtil.capitalizeWithJavaBeanConvention($StringUtil.sanitizeJavaIdentifier($helper.getPropertyName($member.element, $project)))) public Builder add$name($member.type $member.accessor) this.instance.set$name($member.accessor); return this; #end #end public $class0.name build() return this.instance;
参考:
【1】个人博客,http://www.littlefisher.site/2018/04/02/Eclipse%E8%BD%ACIDEA%E6%8C%87%E5%8D%97/
aspnet-codegenerator:没有可用的代码生成器,即使添加了 Microsoft.VisualStudio.Web.CodeGeneration.Design
】aspnet-codegenerator:没有可用的代码生成器,即使添加了Microsoft.VisualStudio.Web.CodeGeneration.Design【英文标题】:aspnet-codegenerator:Nocodegeneratorsavailable,EvenafteraddingMicrosoft.VisualStudio.Web.CodeGeneration.Design【发布时间】:2020-12-14 查看详情
Flutter Doctor - 无法确定是不是安装了 IntelliJ
】FlutterDoctor-无法确定是不是安装了IntelliJ【英文标题】:FlutterDoctor-CannotdetermineifIntelliJisinstalledFlutterDoctor-无法确定是否安装了IntelliJ【发布时间】:2021-08-0815:13:53【问题描述】:FlutterDoctor-无法确定是否安装了IntelliJ我尝试在我... 查看详情
intellij安装angularjs插件
1、先下载angular插件 http://plugins.jetbrains.com/plugin/6971?pr=idea2、打开IntellijIDEA,File—〉Settings---〉Plugins点击“点击“”确定重新启动IntellijIDEA,在Html文件中输入ng,出现提示,则说明插件安装成功: 查看详情
1024codegenerator(代码片段)
答:水一下CodeGeneratorpackagecom.example.springtest;/***@authorLeCodeYang*@version1.0*@description:TODO*@date2022/7/11---15:22*/importcom.baomidou.mybatisplus.annotation.DbType;impo 查看详情
如何使用 CodeGenerator 实现接口的所有成员
】如何使用CodeGenerator实现接口的所有成员【英文标题】:HowtoimplementallmembersofaninterfaceusingCodeGenerator【发布时间】:2021-09-0303:58:15【问题描述】:我正在创建一个VisualStudio扩展,在其中执行某些命令时,应该生成一个.cs文件,其... 查看详情
IntelliJ 找不到已安装的软件包
】IntelliJ找不到已安装的软件包【英文标题】:IntelliJcan\'tfindinstalledpackages【发布时间】:2021-09-1312:01:25【问题描述】:我刚刚安装了IntelliJ并导入了一个Maven/SpringBoot项目。我已将运行配置设置为“应用程序”,但是当我尝试运... 查看详情
intellij Idea 继续安装类型包
】intellijIdea继续安装类型包【英文标题】:intellijIdeakeepsoninstallingtypepackages【发布时间】:2020-11-1000:18:24【问题描述】:我正在使用IntellijIdea2019.2,每当我打开任何节点或React项目时,我的IntelliJ想法都会继续安装类型包,从而减... 查看详情
无法从 intellij 下载/安装 Scala sdk
】无法从intellij下载/安装Scalasdk【英文标题】:Unabletodownload/installScalasdkfromintellij【发布时间】:2018-12-2618:14:29【问题描述】:我在intellij中创建了一个maven项目并尝试下载scalaSDK。我收到以下错误。如果您在以下详细信息中遇到... 查看详情
intellij-插件安装-jrebel热部署插件安装
环境介绍: Win7、JDK1.8、maven+jetty插件、SpringMVC、IntellijIDEA2018.1.2安装插件: 在线安装: Settings-->Plugins-->Browserepositories...-->搜索栏搜索:JRebel-->点击Install按钮安装 离线安装: 1、从官网下载 ht... 查看详情
在 intellij 上“未安装 Git”
】在intellij上“未安装Git”【英文标题】:\'Gitisnotinstalled\'onintellij【发布时间】:2021-06-0911:24:46【问题描述】:您好,我正在尝试将我的java组项目从github链接到intellij。但是我一直遇到Git的这个问题,我下载了它,但我再试一次... 查看详情
IntelliJ 2020.1 版中未安装 Flutter 插件
】IntelliJ2020.1版中未安装Flutter插件【英文标题】:FlutterpluginnotinstalledinIntelliJversion2020.1【发布时间】:2020-09-0501:27:13【问题描述】:当我运行颤振医生命令时,我收到错误“未安装颤振和飞镖插件”。但是在我的插件部分安装了... 查看详情
在现有 IntelliJ Ultimate 安装上安装 Android Studio
】在现有IntelliJUltimate安装上安装AndroidStudio【英文标题】:InstallAndroidStudioonexistingIntelliJUltimateinstallation【发布时间】:2013-05-1022:35:30【问题描述】:我有一个获得许可的IntelliJIdeaUltimate。如何在现有安装的基础上安装AndroidStudio?... 查看详情
npm 是使用 nvm 安装的,但 IntelliJ 不知道它
】npm是使用nvm安装的,但IntelliJ不知道它【英文标题】:npmisinstalledusingnvmbutIntelliJdoesnotknowaboutit【发布时间】:2017-03-0719:43:15【问题描述】:我使用NVM安装了NPM。当我在Intellij终端中使用npm时,它说我没有安装NPM。但是如果我使... 查看详情
在 IntelliJ 2016 中使用 Gradle 安装 Guava
】在IntelliJ2016中使用Gradle安装Guava【英文标题】:InstallGuavawithGradleinIntelliJ2016【发布时间】:2016-10-1709:51:18【问题描述】:让Guava在IntelliJIdea2016中工作的步骤是什么?我是否将以下内容放入build.gradle中?dependenciescompile\'com.google.gu... 查看详情
java环境如何安装?intellij使用以及汉化方法(^_?)☆程序员小知识
...骤0-准备工作步骤1-安装Java步骤2-配置java环境步骤3-安装InteLLiJInteLLiJ安装步骤InteLLiJ汉化步骤(喜欢英文原版的大佬请无视此步)步骤4-使用InteLLiJ创建项目@步骤0-准备工作首先需要下载Java与InteLLiJ,百度网盘下载地址,提取码:x51n(新疆... 查看详情
找不到与命令“dotnet-aspnet-codegenerator”匹配的可执行文件”
】找不到与命令“dotnet-aspnet-codegenerator”匹配的可执行文件”【英文标题】:Noexecutablesfoundmatchingcommand\'dotnet-aspnet-codegenerator\'"【发布时间】:2017-01-0318:34:27【问题描述】:当尝试使用带有Update3的VisualStudio15Enterprise在ASP.NETCor... 查看详情
intelliJ idea - sbt 插件与独立 sbt 冲突
】intelliJidea-sbt插件与独立sbt冲突【英文标题】:inetelliJidea-sbtpluginconflictswithStandalonesbt【发布时间】:2017-07-0108:16:09【问题描述】:我想在Ubuntu上设置Spark-Scala-Sbt开发环境所以我在安装IntelliJ之前分别安装了SBT、Scala。但是在安装... 查看详情
Maven 全新安装在 intellij 中工作,但不在终端中
】Maven全新安装在intellij中工作,但不在终端中【英文标题】:Mavencleaninstallworkinintelijbutnotinterminal【发布时间】:2019-12-0805:44:46【问题描述】:我构建了使用spring-boot-autoconfigure来配置spring上下文的库。我在Intelij中通过mavenconfig构... 查看详情