GWT1.6+Spring3.0+RESTlet+Maven2+openCRX/MDX

本学习笔记转载自:http://opencrx.spaces.live.com/default.aspx

GWT1.6+Spring3.0+RESTlet+Jsonlib+Maven2+openCRX/MDX(一)
身为技术人员竟然一直没有发过技术类博客,有点汗颜,趁着新鲜出炉的最新技术所搭建的最新框架,给大家分享一下。
Spring3.0之前大家集成GWT基本上都是用 GWT- Widget/Server Library ,现在最新的Spring发布包提供了REST支持,使用这种方式更自然。其实这是一个老外的博客上提出来的:http://bigohno.blogspot.com/2009/04/gwt-spring-mvc-and-rest-on-google-app.html

只是这位同志哥只提出了一个概念和其中使用到的一些技术,但是没有细节和代码,我几乎花了近两周的时间才把一个完整的业务流程顺利跑通。当然这也是由于我是第一次使用Gwt1.6,Spring MVC,REST,JSONlib,Restlet,Maven。

也许你们注意到了,除了后台的openCRX/MDX是我研究多年的技术,其他技术除了spring,几乎都是完全没有接触过。然而,也因为这样,当我完成了整个框架基本功能的调试运行之后,得出的结论是:其他技术可以不用,Maven2一定要用,Gwt可以不用,SpringMVC/REST一定要用。

当然了,很多只使用过Ant的同志,对于Maven可能觉得可有可无,够用就好。但是,Maven绝不仅仅是构建,而是帮你管理了整个项目的外部资源、内部构建和单元测试的自动化过程。可以这样说,一旦用过Maven,你就再也不愿意去做没有Maven的项目。

SpringMVC是一个较早出现的技术,以前大家习惯使用Struts1或者2作为MVC的实现框架,Spring技术与之相比并没有太大的优势,所以很多人没有用过SpringMVC包括很多老革命在内。在最新的Spring3.0M2中已经加入了REST,这使得我第一次体验到了Annotation和ViewResolver的强大,当然最关键的起因在于REST本身就是一个非常吸引人的技术框架。而Rest的出现,个人认为是来自于对Ajax框架最好的支持。
前面是宣传一下新技术,下面先给大伙儿上张系统架构图:


对于使用其他后台程序的项目,可以简单的用自己的Service替换openCRX API。说到这里,如果使用Maven进行以来管理和打包,那么会有一个很直接的好处,就是GWT的几个包,不需要手工编写脚本来区分开发时使用和部署时使用,而是简单的配置一下scope属性就可以了。另外需要更新spring最新版本的jar包时,也不需要手工去下载更新,只是简单的修改一下版本号就可以了。
特别要说的是:当使用SpringAOP特性的时候,需要一个cglib2的包,当我自己从网上搜索时下载的包死活无法正常运行,而我简单的加入了SpringAOP自己的pom中所使用的依赖之后,就很顺利的启动了。这让我不禁畅想,如果所有的项目都使用maven发布自己的库,那是多美妙的事情呀。
很遗憾,opencrx/mdx就没有一个自己的maven repository——还好我在网上偶然发现一篇博客介绍一款maven repository代理软件,这下可好了,对于一个项目组的成员或者整个公司来说,都可以搭建这样一个本地库,就可以“一次导入,到处更新”了,哈哈。。。
到这里,相信大家对于这个“最新技术”所组成的“最新框架”应该有一个大致的印象了,下次介绍如何建立一个基于maven 的GWT1.6+Spring3.0的Eclipse工程。

GWT1.6+Spring3.0+RESTlet+Jsonlib+Maven2+openCRX/MDX(二)
前面一篇相当于整个架构的一个概述,这次就是关于如何 使用Maven2快速搭建一个支持GWT1.6和Spring3.0的Eclipse工程,这可以帮助我们用最快的速度开始真正的开发。

1.这里,Maven for Google Appengine Java,是一篇介绍如何基于Maven搭建基于google appengine的工程,我们可以利用它先建好一个gwt的工程,照着图文教程一步步做,之后就会得到一个标准的maven工程。

2.执行mvn eclipse:eclipse,这样可以生成eclipse所需要的工程文件和classpath.这里要注意:如果你不需要支持google appengine那么就需要修改pom.xml文件中,把有关appengine的三个dependency注释掉,并且工程目录下的build.xml也是可以删除的

3.仍然是修改pom.xml文件,加入对于spring3.0的依赖。这里要注意两点:一、前面提到的那篇博客里面所说的加入一个dependency来加入spring3.0的支持,似乎已经过时了,结果是一个包都加不进来。我在网上搜索过很多有关spring3.0 maven的文章,最后只有一个spring官方论坛中的帖子是有效的,但是连接已经找不到了,我就直接贴出这一段dependency了:
<dependency>
            <groupId>asm</groupId>
            <artifactId>asm-commons</artifactId>
            <version>2.2.3</version>
        </dependency>
        <dependency>
            <groupId>asm</groupId>
            <artifactId>asm</artifactId>
            <version>2.2.3</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>org.springframework.core</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>org.springframework.web</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>org.springframework.transaction</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>org.springframework.orm</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>org.springframework.jdbc</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>org.springframework.web.servlet</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>org.springframework.context</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>org.springframework.aop</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>org.springframework.expression</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>org.springframework.test</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.webflow</groupId>
            <artifactId>org.springframework.js</artifactId>
            <version>${webflow.version}</version>
        </dependency>
<dependency>
            <groupId>net.sourceforge.cglib</groupId>
            <artifactId>com.springsource.net.sf.cglib</artifactId>
            <version>2.1.3</version>
        </dependency>
注意:asm和cglib都是spring的依赖包,但有于是可选,所以不能在默认情况下加进工程库中。本来也可以修改相应的spring dependency条目,但是我在公司机器上没有maven pom编辑器,就偷一下懒,直接引用了。大家记得,有条件一定要装一个maven eclipse的插件,特别是pom编辑器的插件,能够极大提高生产力。

4.加入restlet和jsonlib的dependency条目,这两个都可以在网上找到,但是要注意一点:因为他们会依赖spring2.5.6的包,这会和我们现在的spring3.0冲突,所以需要加入一个exclusion条目

5.加入opencrx/mdx依赖,但是实际上opencrx/mdx开发小组沉迷于cvs/ant之中,给我的答复是:现状很好,无须改变。没办法只好自食其力了.
首先,自行定义opencrx/mdx的groupId,artifactId,下面可以参考:
<dependency>
            <groupId>opencrx</groupId>
            <artifactId>opencrx-application</artifactId>
            <version>2.4.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>opencrx</groupId>
            <artifactId>opencrx-base</artifactId>
            <version>2.4.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>opencrx</groupId>
            <artifactId>opencrx-extension</artifactId>
            <version>2.4.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>opencrx</groupId>
            <artifactId>opencrx-kernel</artifactId>
            <version>2.4.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>opencrx</groupId>
            <artifactId>opencrx-mail</artifactId>
            <version>2.4.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>opencrx</groupId>
            <artifactId>opencrx-security</artifactId>
            <version>2.4.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>openmdx.core</groupId>
            <artifactId>openmdx-application</artifactId>
            <version>2.4.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>openmdx.core</groupId>
            <artifactId>openmdx-base</artifactId>
            <version>2.4.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>openmdx.core</groupId>
            <artifactId>openmdx-base-ext</artifactId>
            <version>2.4.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>openmdx.core</groupId>
            <artifactId>openmdx-system</artifactId>
            <version>2.4.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>openmdx.core</groupId>
            <artifactId>tomcat-juli</artifactId>
            <version>2.4.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>openmdx.portal</groupId>
            <artifactId>openmdx-portal</artifactId>
            <version>2.4.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>openmdx.security</groupId>
            <artifactId>openmdx-ldap</artifactId>
            <version>2.4.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>openmdx.security</groupId>
            <artifactId>openmdx-radius</artifactId>
            <version>2.4.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>openmdx.security</groupId>
            <artifactId>openmdx-security</artifactId>
            <version>2.4.1</version>
            <scope>provided</scope>
        </dependency>
其次,手工安装相应的jar包到maven repository。这里有一个可选项,就是在本地网上安装maven repository代理服务器,那么可以统一安装在这台服务器上,所有开发人员可以从这里统一更新所有的开发用jar包。

6.以上整个过程中,如果你是在eclipse环境中,并且安装了maven-elcipse插件,那么每次修改了pom.xml文件,都会自动进行maven upate,这样会验证其中所有的依赖包的有效性。如果没有问题,那么可以执行:mvn install,把整个工程构建并打包到本地maven repository之中。因为本人对于Maven研究还不深入,所以把部署的任务也放到了install之中执行。理论上说,可以增加maven build的run命令在eclipse里面,这样可以更方便。大家如果有知道这个方法的,请告知。

最后总结一下:如果你对maven有更深的了解,就会发现更多的惊喜。同样限于时间,我还没有加入编译gwt的任务到pom中,简单尝试下,可以进行编译但是不能生成静态页面到我指定的目录,等有时间再加上这个吧,这样就可以整合gwt compile和deploy into tomcat的任务了。另外,顺便对比一下maven和ant的build,在maven下一旦包安装好整个过程不超过10s.但是如果没有注释掉appengine就会耗费2分钟以上,我也没去研究这到底是什么原因,大家可以自己研究看看,相信其中可以发现更多的功能和收获更多的开发乐趣。

预告:下次我会从springmvc的设置开始讨论整个框架的运行流程


GWT1.6+Spring3.0+RESTlet+Jsonlib+Maven2+openCRX/MDX(三)
前面一篇主要是关于Maven在整个工程中的使用介绍,以后还会根据情况,介绍一些Tips。

本系列博客中的第一篇中,有一张整个架构的示意图,其中联系前台和后台的是http/Rest标准协议。现在我们就先从前台所使用的技术GWT和Restlet开始。



1.GWT作为一种基于java开发Ajax页面的技术框架,真正的发展是开始于1.5版本(支持了大部分java5的特性和库),到了1.6又再一次进行了大的修订。目前来说,它的最大优势就是支持大量开源的控件,包括gwt-ext,smartgwt等等,和另外一个要强调的,所见即所得的编辑器GWT Designer(目前似乎已经被更名为window builder),有了这两点,对于java/j2ee开发人员来说几乎是接近了C/S时代RAD的开发效率了。可惜的是,对于一个完整的web应用来说web ui仅仅是前台的一部分,在webservice/rest协议出现前,前端展现和后台程序耦合性达到了令人发指的地步。GWT也因此没有更大范围的流行起来,特别是国内,几乎看不到使用gwt成功的案例。难以设计/改变风格,不熟悉/适应这种开发方式,都是让人难以接近的原因。


2.Restlet本身是一个完整的Rest实现框架,包括了前端、后台以及和其他技术的集成模块,我们在这里仅仅使用了和GWT集成的Restlet-GWT模块,大家有兴趣也可以去restlet官方网站查看其它解决方案。不得不说,restlet在对于REST支持的领域上已经远远领先,特别是和GWT的集成上,几乎为开发人员周到的考虑到了方方面面的需求,简化了GWT远程调用的繁琐(2个接口类、一个实现类再加上servlet的申明),对于get/post/put/delete来说,都仅仅几行代码就可以实现,下面是一个get方法的例子:
            public void onClick(Widget sender) {
                // Add an AJAX call to the server
                final Client client = new Client(Protocol.HTTP);
                client.get("http://localhost:8888/ping", new Callback() {
                    @Override
                    public void onEvent(Request request, Response response) {
                        button.setText(response.getEntity().getText());
                    }
                });
                dialogBox.hide();
            }


3.对于页面流程、验证/异常处理以及权限控制,在GWT框架下,都是一种新的挑战,但是也可以借鉴C/S的开发经验。
基于角色和页面的编号,可以处理功能权限,基于角色的参数管理,可以控制相应的数据权限,基于opencrx可以提供SaaS的数据分区控制。验证和异常处理依然可以分成前后台,分别处理。基于GWT,已经简化了web flow的处理,但是也同时绑定了业务处理的部分流程,只有通过尽可能多的重用页面组件来提供工作流程的灵活性。


预告:下次介绍Server端,Spring3.0 MVC/REST的实现,以及opencrx/mdx API的调用

 

相关推荐

openCRX安装手记

本文在windows XP测试环境中安装openCRX,并非正式的安装文档,如有疑问请参考正式文档。

开源CRM-opencrx安装

<!--google_ad_client = "pub-1147974088840251";google_ad_width = 728;google_ad_height = 90;google_ad_format = "728x90_as";google_ad_type = "text_image";google_ad_channel ="";google_color_

上海莱泽 2746

当vCenter的证书过期、Root密码过期、Root密码遗忘同时发生时的解决方法与步骤

vCenter,强制修改root密码,修改SSO User密码,修复证书过期问题

OCTSJimmy的专栏 5563

opencrx(开源CRM)部署

关于opencrx的介绍,可以去以下网站看 [url]http://www.opencrx.org[/url] 中文网站 [url]http://www.opencrx.com.cn[/url] 对于新手,提供了中文傻瓜包,不过只能在windows平台使用 [url]http://www.opencrx.com.cn/crx/download.htm[/u...

weixin_34107955的博客 649

LinuxCNC开发实战:从安装到EtherCAT配置全解析

本文详细解析LinuxCNC开发实战,从系统安装到EtherCAT总线配置全流程。涵盖实时内核优化、伺服驱动器PDO映射、HAL配置及自定义运动学开发,帮助开发者快速搭建工业级数控系统,提升运动控制精度与稳定性。

rgv234567的博客 355

3D Gaussian Splatting:用于实时的辐射场渲染

3D Gaussian Splatting:用于实时的辐射场渲染 3d gaussian splatting for real-time radiance field rendering

m0_51976564的博客 1万+

开源:www.open-open.com (转)

开源:www.open-open.com 关键词: 开源 www.open-ope Spring Framework【Java开源J2EE框架】 Spring是一个解决了许多在J2EE开发中常见的问题的强大框架。 Spring提供了管理业务对象的一致方法并且鼓励了注入对...

weixin_34321753的博客 1133

TC397 EB配置ADC软件触发:从零实现周期采样与中断处理

本文详细介绍了如何在Infineon AURIX TC397芯片上使用EB Tresos工具配置ADC软件触发,实现周期采样与中断处理。通过硬件连接、EB模块配置、代码初始化及数据处理的全流程解析,帮助开发者快速掌握ADC软件触发技术,提升嵌入式系统开发效率。

root9的博客 234

开源crm大全

转自http://www.clovercrm.com/blog/?p=408 Compiere ERP&CRM Compiere ERP&CRM为全球范围内的中小型企业提供综合型解决方案,覆盖从客户管理、供应链到财务管理的全部领域,支持多组织、多币种、多会计模式、多成本计算、多语种、多税制等国际化特性。易于安装、易于实施、易于使用。只需要短短几个小时,您就可以使用申购-采购-发票-付款、报价-订...

yypiao的专栏 566

智能网联汽车云控系统核心解析:车云数据交互协议设计与实践

本文深入解析了智能网联汽车云控系统的核心——车云数据交互协议的设计与实践。文章围绕“说什么”、“怎么说”及异常处理三大核心问题,详细阐述了二进制与结构体数据类型定义、TCP/UDP双通道传输机制、通用报文格式以及典型交互流程(如GLOSA车速引导),并分享了时间同步、坐标系定义等关键实战经验与避坑指南,为构建高效、可靠、安全的车云“神经系统”提供专业指导。

alice7model的博客 122

谈谈人大金仓数据库

人大金仓数据库(Kingbase)是国产自主研发的关系型数据库管理系统,兼容主流数据库语法,支持高并发、高安全性及国产化适配。该数据库提供完整的安装部署方案,包括环境准备、初始化配置和验证流程,并配备专业的数据迁移工具(KDMS)实现从Oracle/MySQL等数据库的平滑迁移。系统提供KStudio等图形化管理工具,支持性能监控、备份恢复等运维功能,同时具备性能调优、高可用架构、分区表管理等高级特性,满足政府、金融等领域的企业级需求。

蜚鸣的博客 2110

【转】Java开源项目(备查)

【转】Java开源项目(备查) Spring Framework 【Java开源 J2EE框架】 Spring 是一个解决了许多在J2EE开发中常见的问题的强大框架。 Spring提供了管理业务对象的一致方法并且鼓励了注入对接口编程而不是对类编程的良好习惯。Spring的架构基础是基于使用JavaBean属性的 Inversion of Control容器。然而,这仅仅是完整图景中的一部...

growing_lin的博客 307

Linux Kernel入门到精通系列讲解 - 总目录

在学习Linux Kernel之前,需要先准备开发环境,方便后续进行开发。可以根据自身情况,选择性阅读该章节。学习该章节之前,你应该了解一下网络概念,明白为什么要讲这些,才能更有方向的去理解学习。Linux ARM平台开发系列讲解(设备树篇) 4.1.1 设备树的原理详解。本项目完全开源,仅供学习使用,如需其他用途,请与本人联系。),本章节你可以学习到。摄像头V4L2子系统、Linux kernel常用的子系统等,ARM架构、RISCV架构、Uboot等。

DSMGUOGUO的博客 1万+

Java开源框架集(全)

Spring Framework 【Java开源 J2EE框架】 Spring是一个解决了许多在J2EE开发中常见的问题的强大框架。 Spring提供了管理业务对象的一致方法并且鼓励了注入对接口编程而不是对类编程的良好习惯。Spring的架构基础是基于使用JavaBean属性的Inversion of Control容器。然而,这仅仅是完整图景中的一部分:Spring在使用IoC容器作为构建完关注所有架构层的完整解决方案方面是独一无二的。 Spring提供了唯一的数据访问抽象,包括简单和有效率的JDBC框.

yangguoqi的专栏 8042

LVS 负载均衡面试题及参考答案

什么是 LVS 负载均衡?它的主要作用是什么? LVS(Linux Virtual Server)是一个基于 Linux 内核的开源负载均衡项目。它通过将请求流量按照一定的算法分发到后端的多个真实服务器(Real Server)上,从而实现负载均衡的功能。 从原理上来说,LVS 工作在网络层和传输层之间。当客户端发起请求时,请求首先到达 LVS 服务器,LVS 会根据预先设定的规则和算法,比如轮询(Round - Robin)、加权轮询(Weighted Round - Robin)、最少连

大模型大数据攻城狮的专栏 1470

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

我看准的Open Source的CRM

第一感觉都不错。准备先在单位的机器上试一试,不知道放在虚拟主机上会是什么样子.Compiere ERP + CRM Business SolutionSmart ERP+CRM solution for Small-Medium Enterprises in the global market covering all areas from order and customer/supplier

东哩个东 2113

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

最新JAVA开源项目

 Spring Framework  【Java开源 J2EE框架】Spring是一个解决了许多在J2EE开发中常见的问题的强大框架。 Spring提供了管理业务对象的一致方法并且鼓励了注入对接口编程而不是对类编程的良好习惯。Spring的架构基础是基于使用JavaBean属性的Inversion of Control容器。然而,这仅仅是完整图景中的一部分:Spring在使用IoC容器作为

James的专栏 1516

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain&#39;s apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath(&#39;DeepLearnToolbox&#39;));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand(&#39;state&#39;,0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W&#39;); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand(&#39;state&#39;,0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = &#39;sigm&#39;;%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, &#39;Too big error&#39;);```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand(&#39;state&#39;,0)sae = saesetup([784 100]);sae.ae{1}.activation_function = &#39;sigm&#39;;sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)&#39;)% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;;nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, &#39;Too big error&#39;);```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x&#39;,28,28,60000))/255;test_x = double(reshape(test_x&#39;,28,28,10000))/255;train_y = double(train_y&#39;);test_y = double(test_y&#39;);%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you&#39;ll get around 1.2% errorrand(&#39;state&#39;,0)cnn.layers = { struct(&#39;type&#39;, &#39;i&#39;) %input layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 6, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %sub sampling layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 12, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, &#39;Too big error&#39;);```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, &#39;Too big error&#39;);%% ex2 neural net with L2 weight decayrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex3 neural net with dropoutrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex4 neural net with sigmoid activation functionrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex5 plotting functionalityrand(&#39;state&#39;,0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = &#39;softmax&#39;; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand(&#39;state&#39;,0)nn = nnsetup([784 20 10]); nn.output = &#39;softmax&#39;; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

idea 无法识别 maven 项目

再按上面方式重新导入。

张紫娃的博客 241

Maven Setting详解

全局 settings.xml 是 maven 的全局配置文件,一般位于 ${maven.home}/conf/settings.xml,即 maven 文件夹下的 conf 中。用户 setting 是 maven 的用户配置文件,一般位于 ${user.home}/.m2/settings.xml,即每位用户都有一份配置文件。pom.xml 文件是项目配置文件,一般位于项目根目录下或子目录下。配置优先级从高到低:pom.xml > 本地 settings > 全局 settings。

sxlishaobin的博客 179

Maven 聚合工程实读:10 个模块混用 Spring 2.0.8 与 3.0.5、Struts 1 与 2,我是怎么把账算清的

一个真实企业 Maven 聚合工程实读:10 个模块、86656 行 Java、6 个 war,同一 reactor 里混用 Spring 2.0.8 与 3.0.5、Struts 1.2.6 与 2.2.1,四个 war 各抄一份 Spring 配置,src/test 全空。我逐个模块统计打包方式、框架版本、配置对应关系,列出可低成本动手的三件事:路由对应测试、构建可重复性、配置去重。

qq_28884591的博客 622

Maven 构建产物 `.flattened-pom.xml` 解析与工程化规范

.flattened-pom.xml是Maven构建时由flatten-maven-plugin生成的派生文件,用于将开发态动态POM转化为发布态纯净依赖描述,解决变量解析及配置污染问题。该文件属构建产物,必须加入.gitignore并在IDEA中隐藏;若已误提交需通过git rm --cached清理。Maven 4引入原生Consumer POM后,该插件将逐步退场。

小李同学的博客 175
上一篇: Hibernate Qbc分组查询
下一篇: Flex通过RemoteObject取java列表绑定到DataGrid
lglovejava
博客等级 码龄20年 1粉丝 2原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值