基于配置文件生成代码|sublime怎么自动生成代码



Ⅰ mybatis代码生成的几种方式

第一种:使用命令行创建第二种:通过MybatisGenerator类和配置文件生成代码第三种方式 通过GeneratorAntTask类和配置文件生成第四种:基于Maven插件的方式第五种:通过eclipse mybatis generater代码生成插件自动生成代码

Ⅱ 如何基于Hibernate在java类中实现,根据数据库表生成持久化类代码和映射文件hbm.xml

这个就要借助hibernate tools跟xdoclet来完成了;首先你要在你的java代码里应用xdoclet标签,例如Java codeprivate String name;/*** @hibernate.property column = "name" length = "50"*/public String getName() { return this.name;}public void setName(String name) { this.name = name;}其中,写到javadoc上的@hibernate.property column = "name" length = "50"就是xdoclet标签,它需要xdoclet程序来处理,这里就需要用到hibernate tools。具体做的话一般情况是建一个ant脚本来完成,例如:XML code<target name="hibernate-xdoclet" depends="init, init-xdoclet_hibernate" description="Generate mapping documents"> <echo>+—————————————————+</echo> <echo>| |</echo> <echo>| R U N N I N G H I B E R N A T E D O C L E T |</echo> <echo>| |</echo> <echo>+—————————————————+</echo> <delete> <fileset dir="${hibernate.cfg.xml.dir}" includes="hibernate.cfg.xml" /> </delete> <echo message="hibernate.cfg.xml at ${hibernate.cfg.xml.dir}"></echo> <sleep seconds="1"/> <hibernatedoclet destdir="${hibernate.cfg.xml.dir}" excludedtags="@version,@author,@todo,@see" addedtags="@xdoclet-generated at ${TODAY},@right The XDoclet Team,@author XDoclet,@version ${version}" force="false" verbose="true"> <fileset dir="${src.dir}"> <include name="com/**/model/**/*.java"/> </fileset> <hibernatecfg version="3.0" destDir="${hibernate.cfg.xml.dir}" dialect="org.hibernate.dialect.Oracle9Dialect" driver="oracle.jdbc.driver.OracleDriver" jdbcUrl="jdbc:oracle:thin:@localhost:1521:RESDL" userName="test" password="123" showSql="true" schema="true" validateXML="true" /> <hibernate version="3.0"/> </hibernatedoclet> </target>上面的代码是生成hbm跟cfg文件的,下面再介绍如何从java类到数据库:XML code<target name="hibernate-schema" depends="init, init-hibernate-schema" description="Generate DB schema from the O/R mapping files"> <echo>+—————————————————+</echo> <echo>| |</echo> <echo>| R U N N I N G D B S C H E M A |</echo> <echo>| |</echo> <echo>+—————————————————+</echo> <echo message="mysql.sql at etc/hbm2doc"></echo> <sleep seconds="1"/> <hibernatetool destdir="etc/hbm2doc"> <configuration propertyFile="${src.dir}/hibernate.properties"> <fileset dir="${hibernate.cfg.xml.dir}"> <include name="com/**/model/**/*.hbm.xml"/> </fileset> </configuration> <hbm2ddl drop="true" outputfilename="mysql.sql"/> <hbm2doc/> </hibernatetool> </target>当然ant工程里的一些初始化需要自己定义,我这里只摘录关键部分,具体的东西请查阅相关文档,hibernate tutorail里就有个例子

Ⅲ 易语言写配置文件

1、打开“易语言主程序”,进入“新建易语言工程文件”对话框,果断选择第一个“Windows窗口程序”然后点击“确定”按钮,进入易语言窗口程序设计界面。

Ⅳ 怎么样根据hibernate的配置文件生成

怎么样根据hibernate的配置文件生成1.一般在scr下面新建一个属性文件*.properties,如a.properties然后在Java程序中读取或操作这个属性文件。代码实例 属性文件a.properties如下:name=rootpass=liukey=value读取a.properties属性列表,与生成属性文件b.properties。代码如下:1 import java.io.BufferedInputStream; 2 import java.io.FileInputStream; 3 import java.io.FileOutputStream; 4 import java.io.InputStream; 5 import java.util.Iterator; 6 import java.util.Properties; 7 8 public class PropertyTest { 9 public static void main(String[] args) { 10 Properties prop = new Properties(); 11 try{12 //读取属性文件a.properties13 InputStream in = new BufferedInputStream (new FileInputStream("a.properties"));14 prop.load(in); ///加载属性列表15 Iterator<String> it=prop.stringPropertyNames().iterator();16 while(it.hasNext()){17 String key=it.next();18 System.out.println(key+":"+prop.getProperty(key));19 }20 in.close();21 22 ///保存属性到b.properties文件23 FileOutputStream oFile = new FileOutputStream("b.properties", true);//true表示追加打开24 prop.setProperty("phone", "10086");25 prop.store(oFile, "The New properties file");26 oFile.close();27 }28 catch(Exception e){29 System.out.println(e);30 }31 } 32 }getProperty/setProperty这两个方法是分别是获取和设置属性信息。Properties类继承自Hashtable类并且实现了Map接口,也是使用一种键值对的形式来保存属性集。不过Properties有特殊的地方,就是它的键和值都是字符串类型。*.properties文件的注释用#。配置数据的时候是以键值对的形式,调用的时候和修改的时候也是操作键值对。2.当然还可以用*.xml来配置,位置一般在一个包下面。例如com.styspace包下面的config.properties文件。xml version="1.0" encoding="gbk"?> <Accounts> <Account type="by0003"> <code>100001</code> <pass>123</pass> <name>李四</name> <money>1000000.00</money> </Account> </Accounts>现在操作config.properties文件。import org.apache.commons.configuration.Configuration; import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.configuration.PropertiesConfiguration; public class peropertiesLoaderTest { public static void main(String[] args) throws ConfigurationException{ Configuration config = new PropertiesConfiguration("com/styspace/config.properties"); String name = config.getString("name"); System.out.println("name:" + name); } }

Ⅳ 如何在idea中使用Mybatis-generator插件快速生成代码

IntelliJ idea 开发工具的相关资料很少,加大了大家入手的难度,今天就以mybatis的插件安装做下示例,可能对于已经会用的人不值一提但是对于我们这些天资一般刚开始使用,我想还是会有些帮助。安装步骤:1.下载插件mybatis 插件 插件下载完毕,存放指定位置,文件名默认应该是:mybatis-plus.jar2.打开Intellij idea工具,打开菜单 File –> settings 选择 Plugs,点击Install plug from disk,选择刚刚下载的插件jar文件,确认后,会直接显示mybatis插件和其信息,表示安装成功。3.插件安装后,打开settings,会有Mybatis一项!

Ⅵ sublime怎么自动生成代码

1、首先要熟悉sublime api,插件可以用python开发,这个很好,写好代码,保存到默认的目录应该是\SublimeText2\Data\Packages\User下面,可以按下快捷键Ctrl + ‘ 打开SublimeText的控制台,执行如下命令就可以运行刚刚写的小插件,测试效果:Java代码 view.run_command('insert_signature') 2、为了方便使用需要绑定快捷键,在同目录下\SublimeText2\Data\Packages\User 有快捷键文件 Default (操作系统类型).sublime-keymap 3个类似的文件,修改绑定快捷键即可,如下:自动生成代码头 代码如下:Java代码 #coding=gbk ''' Created on — :: @author: songpo ''' #view.run_command('insert_codeheader') import sublime, sublime_plugin, datetime class insertSignatureCommand(sublime_plugin.TextCommand): def run(self, edit): date = datetime.datetime.now() dateStr = date.strftime("%Y-%m-%d %X") text_encode = """#-*- encoding: utf- -*-\n'''\n""" text_author = """\n\[email protected]: songpo\n'''\n""" text = text_encode + 'Created on ' + dateStr + text_author #for region in the selection #一个region是一个选择块,一次可以选择多个块 for r in self.view.sel(): str_r = self.view.substr(r)#str_r是所选择块的文本内容 if 'Created on ' in str_r: if 'Updated on ' in str_r: text = str_r[:str_r.find('Updated on')] + 'Updated on ' + dateStr + text_author else: text = str_r.replace(text_author, '\nUpdated on' + dateStr + text_author) self.view.erase(edit, r) self.view.insert(edit, r.begin(), text) 参考博客:http://www.cnblogs.com/restran/archive/2013/01/07/2850254.html1、自定义快捷键: sublime的操作体验完全基于配置,如有你愿意多调整,完全可以按照自己的意愿重新定义一个操作体验,有2个快捷键配置文件系统和用户,应该是用户的可以覆盖系统的,在preferences-按键绑定-系统/用户 即可打开配置。小试一下增加一个eclipse的功能,就是上下调整选中行,添加如下代码:Java代码 { "keys": ["alt+up"], "command": "swap_line_up"}, { "keys": ["alt+down"], "command": "swap_line_down"}, 2、Sublime Text 2 的快捷键还支持双重组合,譬如默认情况下,将选中的文字改成大写的热键是“Ctrl+K, Ctrl+U”,意思是当你先按下 Ctrl+K 之后迅速再按 Ctrl+U 进行触发(只按下Ctrl+K是没有作用的),这样可以避免很多热键冲突,也可以更灵活更多选择地进行热键自定义3、常用快捷键:Shift+鼠标右键 (Win) 或 Option+鼠标左键 (Mac) 或使用鼠标中键可以用鼠标进行竖向多行选择ctrl+p:雷电般快速的文件切换:Ctrl+P(Win),这次试试先输入一个 @ 号:随心所欲的跳转:快速罗列与定位函数/HTML的元素、跳转到指定行更牛x的了来了,这些切换定位方法你还可以配合在一起使用!譬如我有一个名为”hello-iplaysoft.js”的文件,里面其中有一个function叫做”visit_iplaysoft_com”,我现在想要编辑这个函数,那么我只需按下 Ctrl+P,然后输入“[email protected]”回车(模糊匹配,注意前面有颜色的字符),ST2 马上就给我到打开这个文件并定位进去了!够方便了吧?!熟记这几个快捷键,你可以很一气呵成地进行文件切换和编辑------------------------------------------------一下是mac版本配置--------------------------------------------------看考地址:https://wido.me/sunteya/sublime-text-packages-and-settings/1、Sublime Text 常用插件和设置打开 Sublime Text 2 后, 可以在菜单中找到 Preferences -> Settings – User 点击后, 会打开一个编辑器窗口. 在该编辑器窗口下, 就可以输入当前用户的关配置了. 我一般配置如下:Java代码 { "color_scheme": "Packages/Color Scheme – Default/Monokai.tmTheme", "dictionary": "Packages/Language – English/en_GB.dic", "font_size": 11.0, "draw_white_space": "all",// 显示空白字符, 比如 空格 tab "font_size": 13.0, "scroll_past_end": true,// 当文件到末尾时还能继续滚动 "trim_automatic_white_space": false, // 关闭自动删除每行前后空格 "ignored_packages": [ "Vintage" ] } 2、Package Control 下载插件(格式化xml)Package Control 是用来管理 Sublime Text 2 的插件的插件. 也是装完后第一个要安装的插件.首先打开 ctrl+`, 并在打开的 st2 console 中输入:Java代码 import urllib2,os; pf='Package Control.sublime-package'; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read()); print 'Please restart Sublime Text to finish installation' 安装完成后, 应该就可以看到菜单下有 Preferences -> Package Settings 选项了.常用插件上面的 Package Control 安装完以后, 就可以通过快捷键 command + shift + p 并输入 install package, 来选择需要安装的插件.Alignment这插件用于对齐代码赋值语句, 例如:var name = "sublimt"var version = "2.0.1"var title = "sublime text"按下快捷键后, 会变成:var name = "sublimt"var version = "2.0.1"var title = "sublime text"不过这插件默认使用的是 ctrl + cmd + a 和 那个抢了 5个全局个快捷键的QQ冲突, 所以需要修改插件的快捷键. 点击菜单 Preferences -> KeyBindings – User, 加入如下内容{ "keys": ["super+ctrl+alt+]"], "command": "alignment" }将快捷键修改成 ctrl + opt + cmd + ], 要改成什么其他的也请自行修改.Vim 模式是的,Sublime Text 2 dev 版已经支持 Vim 的编辑模式了,如果更喜欢 Vim 的编辑模式,可以通过以下方法来激活 Vintage mode:按下 Shift + Command + P 调出命令面板。输入 settings user 调出 Preferences:Settings – User,并按下回车。以上两步也可以直接用cmd + ,完成。这时会打开一个 Preferences.sublime-settings 的文件,如果是第一次修改,它应该是个空文件,把以下文本粘贴进去:Java代码 { "ignored_packages": [] } 保存这个文件,这时按下 ESC 键,再按下一些你熟悉的 Vim 命令,是不是很有亲切感

Ⅶ 如何使用myeclipse自动生成配置文件

1、右键项目;

2、选择MyEclipse;

3、点击add struts Capability;

4、选择Strunt2,点击完成;

5、在项目的src目录下已经自动生成了配置文件。

Ⅷ 如何创建.ini配置文件

1、说明:python3使用configparser模块来处理ini配置文件。2、代码示例:需要生成conf.ini配置文件如下:[config]v1 = 100v2 = abcv3 = truev4 = 123.45python代码:import configparser# 加载现有配置文件conf = configparser.ConfigParser()# 写入配置文件conf.add_section('config') #添加section# 添加值conf.set('config', 'v1', '100')conf.set('config', 'v2', 'abc')conf.set('config', 'v3', 'true')conf.set('config', 'v4', '123.45')# 写入文件with open('conf.ini', 'w') as fw: conf.write(fw)# 读取配置信息v1 = conf.getint('config', 'v1')v2 = conf.get('config', 'v2')v3 = conf.getboolean('config', 'v3')v4 = conf.getfloat('config', 'v4')print('v1:', v1)print('v2:', v2)print('v3:', v3)print('v4:', v4)打开conf.ini文件检查内容3、模块常用函数:1)读取配置文件read(filename) 直接读取ini文件内容sections() 得到所有的section,并以列表的形式返回options(section) 得到该section的所有optionitems(section) 得到该section的所有键值对get(section,option) 得到section中option的值,返回为string类型getint(section,option) 得到section中option的值,返回为int类型,还有相应的getboolean()和getfloat() 函数。2)写入配置文件add_section(section) 添加一个新的sectionset( section, option, value) 对section中的option进行设置,需要调用write将内容写入配置文件。

Ⅸ 怎样利用 eclipse mybatis generator 自动生成代码

MyBatis中,可以使用Generator自动生成代码,包括DAO层、 MODEL层 、MAPPING SQL映射文件。 第一步:下载MyBatis的Generator工具 htt p:/ /mybati s.gith ub.i o/generator/第二步:配置自动生成代码所需的XML配置文件,例如(generator.xml) 将这个文件保存至你下载的mybatis-generator-core-1.3.2文件夹下 第三步:进入XML配置文件(generator.xml)所在的的目录并执行命令:Dos代码 java -jar E:\mybatis-generator-core-1.3.2\lib\mybatis-generator-core-1.3.2.j ar -configfile generator.xml -overwritemybatis generator eclipse插件的安装打开eclipse,点击Help>Software Update选择 "Available Software" 标签,点击 "Add Site" 按钮输入以下信息:Location:htt p:/ /mybatis.googleco de.c om/svn/sub-projects/gen erator/trunk/eclipse/UpdateSite/点击ok,自动进入"mybatis generator Feature"点击“install”按钮进行安装。。。。mybatis generator 插件安装完成配置Mybatis Generator不要生成Example类Mybatis Generator默认设置会生成一大堆罗哩罗嗦的Example类,主要是用各种不同的条件来操作数据库,大部分是用不到的,用到的时候手工修改mapper和接口文件就行了。<</code>tableschema="general"tableName="tb_table_name"domainObjectName="EntityName"enableCountByExample="false"enableUpdateByExample="false"enableDeleteByExample="false"enableSelectByExample="false"selectByExampleQueryId="false">name="useActualColumnNames"value="true"/></</code>table>这样生成的mapper和接口就清爽多了。

Ⅹ SBO的配置文件怎么生成

通过文件执行。文件的执行,我们就会得到两个配置文件,分别用于训练阶段和验证阶段。这种方式生成配置文件,必须有个前提,就是要先把原始图片转换成LMDB文件才行。如果我们已经把原始图片做成了一个列表清单(txt文件,一行一张图片),则可以不用LMDB格式作为输入数据,可以用ImageData作为数据源输入,有一个代码,即第一层由原来的Data类型,变成了ImageData类型,不需要LMDB文件和均值文件,但需要一个txt文件。


赞 (0)