无意间听说58开源的消息,我辈欣喜异常。一方面感谢开源同仁的辛苦劳动,另一方面也为我辈在互联网技术实践圈外的人提供了一条实践的渠道。
我迫不及待的从github上download下开源源码,遗憾的是,直接使用“mvn jetty:run”并没有能够跑起来,更遗憾的是,很多人都遇到了这个问题,
但是高手们并没有搭理他们。我决定当这个好为人师的嫌人。
关于Argo的介绍我这里就不写了,相信能看到这篇文章的人都是循着搜索引擎来的。直接入正题。
首先:进入..\Argo\core目录,执行mvn package
这里会Building 58.com argo 1.0.0生成 ..Argo\core\target\argo-1.0.0.jar
然后,将该包加入仓库:
执行mvn install:install-file -DgroupId=com.bj58.spat -DartifactId=argo -Dversion=1.0.0 -Dpackaging=jar -Dfile=D:\Argo\core\target\argo-1.0.0.jar
现在进入..\Argo\samples\hello-world
修改文件夹中的pom.xml,增加一些dependency
修改后的内容如下:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <groupId>com.bj58.spat</groupId> <artifactId>argo-hello-world</artifactId> <version>1.0.0</version> <modelVersion>4.0.0</modelVersion> <packaging>war</packaging> <dependencies> <dependency> <groupId>com.bj58.spat</groupId> <artifactId>argo</artifactId> <version>1.0.0</version> </dependency> <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>13.0.1</version> </dependency> <dependency> <groupId>com.google.inject</groupId> <artifactId>guice</artifactId> <version>3.0</version> </dependency> <dependency> <groupId>org.javassist</groupId> <artifactId>javassist</artifactId> <version>3.17.1-GA</version> </dependency> <dependency> <groupId>org.apache.velocity</groupId> <artifactId>velocity</artifactId> <version>1.7</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.7.2</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.7.2</version> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.16</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <scope>provided</scope> <version>3.0.1</version> </dependency> <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>6.8</version> <scope>test</scope> </dependency> <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-all</artifactId> <version>1.9.5</version> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.3</version> <configuration> <failOnMissingWebXml>false</failOnMissingWebXml> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.5.1</version> <configuration> <source>1.6</source> <target>1.6</target> <encoding>UTF-8</encoding> </configuration> </plugin> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.0</version> <configuration> <path>/</path> <!--/argo --> <port>80</port> </configuration> </plugin> <plugin> <!-- http://wiki.eclipse.org/Jetty/Feature/Jetty_Maven_Plugin --> <groupId>org.mortbay.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <configuration> <stopPort>9966</stopPort> <stopKey>foo</stopKey> <scanIntervalSeconds>0</scanIntervalSeconds> <connectors> <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector"> <port>80</port> <maxIdleTime>60000</maxIdleTime> </connector> </connectors> <webAppConfig> <contextPath>/</contextPath> </webAppConfig> </configuration> </plugin> </plugins> </build> </project>
ok,最后一步了,执行mvn jetty:run,jetty运行起来了
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ argo- hello-world --- [INFO] Compiling 8 source files to D:\Argo\samples\hello-world\target\test-class es [INFO] [INFO] <<< jetty-maven-plugin:8.1.14.v20131031:run (default-cli) @ argo-hello-wo rld <<< [INFO] [INFO] --- jetty-maven-plugin:8.1.14.v20131031:run (default-cli) @ argo-hello-wo rld --- [INFO] Configuring Jetty for project: argo-hello-world [INFO] webAppSourceDirectory not set. Defaulting to D:\Argo\samples\hello-worldsrc\main\webapp [INFO] Reload Mechanic: automatic [INFO] Classes = D:\Argo\samples\hello-world\target\classes [INFO] Context path = / [INFO] Tmp directory = D:\Argo\samples\hello-world\target\tmp [INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml [INFO] Web overrides = none [INFO] web.xml file = null [INFO] Webapp directory = D:\Argo\samples\hello-world\src\main\webapp 2014-04-06 00:24:39.834:INFO:oejs.Server:jetty-8.1.14.v20131031 2014-04-06 00:24:40.150:INFO:oejpw.PlusConfiguration:No Transaction manager foun d - if your webapp requires one, please configure one. file类型的扫描 jar类型的扫描 2014-04-06 00:24:41.928:INFO:/:initializing Argo... 2014-04-06 00:24:41.929:INFO:/:preparing an injector 2014-04-06 00:24:42.088:INFO:/:injector completed 2014-04-06 00:24:42.356:WARN:oejsh.RequestLogHandler:!RequestLog 2014-04-06 00:24:42.373:INFO:oejs.AbstractConnector:Started SelectChannelConnect or@0.0.0.0:80 [INFO] Started Jetty Server
Now,访问http://localhost/,看到如下页面,恭喜你,成功了。
Samples 根据url获得参数的hello wolrd 静态文件显示 区分queryString和form参数 文件上传展示