设为首页 收藏本站
查看: 675|回复: 0

[经验分享] Flex 中Maven的使用

[复制链接]

尚未签到

发表于 2017-2-28 07:00:06 | 显示全部楼层 |阅读模式
  Maven是为了简化Java项目的构建而建立的工具,通过设置相关的依赖等信息可以自动从网络下载对应的版本的库。
  Flex的开发资源中有很多都是和Java端集成的,因此网络上很多的项目都是基于Maven形式的,如果搞不定这个,那运行这些例子估计很困难。
  上一篇 http://www.cnblogs.com/2018/archive/2011/06/02/2067641.html 主要是Flash Builder等IDE中的使用,这个主要讲讲命令行的形式构建,毕竟Java的环境下这个形式还是很多的。对于.net的开发者来说,这个过程也算一个小的挑战(不同的版本、各种的设置、版本冲突等等,不过一些都是开源的资料还是比较多的,不过需要花功夫去学习和理解)
  主页:http://Maven.apache.org/download.html
  常用名令:http://blog.csdn.net/shangpusp/archive/2010/02/07/5297340.aspx
  如果需要详细了解Maven的信息,参考这个简明的手册(一百多页): http://www.sonatype.com/index.php/Support/Books/Maven-By-Example
Maven Eclipse Plug-in
  可以在Eclipse中安装下面的插件,这样就可以IDE建立和使用Maven的项目了
  http://m2eclipse.sonatype.org/sites/m2e
  http://m2eclipse.sonatype.org/sites/m2e-extras
plug-in
  mvn clean 使用core plug-in
  mvn jetty:run 需要在pom.xml.中指定Jetty plug-in
  Maven plug-ins列表参考地址:
  http://mvnrepository.com/
  Maven 配置的三个层面:
  ·  Project: most static configuration occurs in pom.xml 在项目文件Pom.xml
  ·  Installation: (Maven installation)/conf/setting的安装层次
  ·  User:  特定用户 ${user.home}/.m2/setting.xml
  以上三个不同的配置信息可以根据实际情况选择配置
Jetty配置例子
  项目中一般使用JSP容器进行运行的测试方法,此处使用Jetty
  Jetty 的POM XML文件
  <plug-in>
  <groupId>org.mortbay.jetty</groupId>
  <artifactId>Maven-jetty-plug-in</artifactId>
  <version>6.1.19</version>
  <configuration>
  <contextPath>/yourContextRoot</contextPath>
  <scanIntervalSeconds>4</scanIntervalSeconds>
  <scanTargetPatterns>
  <scanTargetPattern>
  <directory>
  src/main/webapp/WEB-INF
  </directory>
  <excludes>
  <exclude>**/*.jsp</exclude>
  </excludes>
  <includes>
  <include>**/*.properties</include>
  <include>**/*.xml</include>
  </includes>
  </scanTargetPattern>
  </scanTargetPatterns>
  </configuration>
  </plug-in>
  Maven中配置Jetty
  http://maven.apache.org/settings.html
  D:\softwares\apache-maven-2.2.1\conf\settings.xml
  <pluginGroups>
  <!-- pluginGroup
  | Specifies a further group identifier to use for plugin lookup.
  <pluginGroup>com.your.plugins</pluginGroup>
  -->
  <pluginGroup>org.mortbay.jetty</pluginGroup>
  </pluginGroups>
其他配置和本地安装例子
  配置Spring 库自动下载的例子:
  <dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring</artifactId>
  <version>2.5.2</version>
  </dependency>
  <dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-test</artifactId>
  <version>2.5.2</version>
  <optional>true</optional>
  </dependency>  
  Maven 现在本地仓库中找依赖组件(${user.home}/.m2/目录下),然后在远程仓库中找,如果都没有找到,提示自己安装。
  自己本地安装的方法:

  • 先找到相关的库文件
  • mvn install:install-file -DgroupId= org.springframework -DartifactId=spring –Dversion=2.5.2 -Dpackaging=jar -Dfile=spring-2.5.2 .jar
  以上命令就把相关内容安装到本地仓库 ${home}/.m2/repository/
archetype
  Basically, an archetype is like a template for your project that is reusable for similar projects. The archetype will create the directory structure, including all the files needed, and download all plug-ins and dependencies needed by the project, saving you a lot of time in the creation and configuration of your project. [意思就是可以建立项目的框架架构,这样以后其他的项目可以在这些框架结构基础上再发展]
  以上是两个构建Flex的archetype.
FNA
  FNA is an open source project started by Adobe consulting that helps Java and Flex development with open source projects and Maven archetypes. You can see and read more about FNA at http://code.google.com/p/fna-v2/ You can find more interesting and useful Flex-Java archetypes at http://fna-v2.googlecode.com/svn/trunk/mvn_archetypes/such as:
  ·  flex-cairngorm-stubbed-crud-archetype
  ·  flex-cairngorm-flexunit-archetype
  ·  flex-library-archetype
Flex Mojos Maven plugin
  http://flexmojos.sonatype.org/
  http://www.sonatype.com/book
  http://flexmojos.sonatype.org/getting-started.html
  一个例子:
  mvn archetype:create -DarchetypeGroupId=org.foj -DarchetypeArtifactId=flex-mojos-archetype -DarchetypeVersion=1.0-SNAPSHOT -DgroupId=org.foj -DartifactId=flex-bugs-ria -DremoteRepositories=http://flexonjava.googlecode.com/svn/repository
  http://filippodipisa.artifactoryonline.com/filippodipisa/libs-releases-local/archetype-catalog.xml  
命令
  编译源代码
  mvn compile
  测试代码
  mvn test
  构建项目[编译测试]并安装到repository
  mvn install
  构建项目[编译不测试]并安装到repository
  mvn install –DskipTests
  编译测试和安装
  指定测试的Flash文件
  mvn install -DflashPlayer.command=d:\FlashPlayer.exe
  打包
  mvn package
  把webapp打部署到Jetty运行
  mvn jetty:run
把webapp打到war 包并自动部署到Jetty运行

  mvn jetty:run-war
  生成eclipse项目
  mvn eclipse:eclipse  清除mvn eclipse:clean
  生成Flex/Flash Builder项目
  mvn flexmojos:flexbuilder
  [http://www.sonatype.com/books/mvnref-book/reference/flex-dev-sect-goals.html#flex-dev-sect-flexbuilder ]
  有了这些知识,对于Java和Flex集成时涉及的很多自动化Maven构建项目可以参考使用了。
  .net下的nuget http://www.nuget.org/ 和maven目前也基本是相同的功能,只不过是.net的领域,看来两者是不断的互相学习和进步。

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-348069-1-1.html 上篇帖子: http文件上传框架选择 下篇帖子: 试用 Nexus OSS 3.0 的docker仓库 (一)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表