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
命令
有了这些知识,对于Java和Flex集成时涉及的很多自动化Maven构建项目可以参考使用了。
.net下的nuget http://www.nuget.org/ 和maven目前也基本是相同的功能,只不过是.net的领域,看来两者是不断的互相学习和进步。
相关推荐
使用Maven对Flex项目进行构建,无需依赖于FlexBuilder进行编译开发。
利用Maven搭建的Java SSH框架后台,利用Flex显示 利用Maven搭建的Java SSH框架后台,利用Flex显示 利用Maven搭建的Java SSH框架后台,利用Flex显示 利用Maven搭建的Java SSH框架后台,利用Flex显示 利用Maven搭建的...
Maven构建并管理Flex项目入门.pdf Maven简单实用教程.docx OTNVD_WebLogicServerDevelopment_CN.pdf 《Maven实战》(国内首本Maven著作)(Maven的安装、配置及使用入门) 《Maven权威指南》.pdf.pdf
NULL 博文链接:https://olive009.iteye.com/blog/2250142
Maven构建全栈式Flex、BlazeDS和Spring集成解决方案–第一部分_创建Maven_Flex模块
NULL 博文链接:https://kamismile.iteye.com/blog/1401235
flex-messaging类包是flex结合JAVA开发通信使用
构建全栈式Flex、BlazeDS和Spring集成解决方案–第一部分 创建Maven Flex模块
使用Maven Dependency插件进行优化 8.6. 最终的POM 8.7. 小结 II. Maven Reference 9. 项目对象模型 9.1. 简介 9.2. POM 9.2.1. 超级POM 9.2.2. 最简单的POM 9.2.3. 有效POM 9.2.4. 真正的POM 9.3. ...
maven-flex2-plugin-1.0.jar
maven-flex2-plugin-support-1.0.jar
maven-flex2-plugin-1.3-sources.jar
Maven构建全栈式Flex、BlazeDS和Spring集成解决方案–第三部分_整合全部应用
Flex与Java整合demo Flex Java 整合 demo
maven-flex2-plugin-support-1.0-sources.jar
Maven构建全栈式Flex、BlazeDS和Spring集成解决方案–第二部分_编写to-do_list服务器端
NULL 博文链接:https://madfroghe.iteye.com/blog/935337
Maven与Eclipse开发环境的配置指导,也包含了对Flex的支持(原创)
JBoss作为应用服务器、MySQL作为数据存储、Hibernate完成数据访问、Spring用来构建业务层、BlazeDS作为远程服务、 Flex用来构建富客户端,使用Maven及flex-compiler-mojo插件进行项目构建,打造全栈式Flex、BlazeDS...
一个以pureMVC为flex前端框架,blazeds为通信服务器,spring和hibernate为服务端框架,实现了增删改等功能的完整实例,数据库使用mysql,部分关键地方加了注释,enjoy!