zoukankan      html  css  js  c++  java
  • [58 Argo]58同城开源web框架Argo搭建实践

    无意间听说58开源的消息(Long long ago),我辈欣喜异常。

    一方面感谢开源同仁的辛苦劳动,另一方面也为我辈在互联网技术实践圈外的人提供了一条实践的渠道。

    我迫不及待的从github上download下开源源码,兴冲冲的cd到hello-world目录下:

    遗憾的是,直接使用“mvn jetty:run”并没有能够让hello项目跑起来,更遗憾的是,很多人都遇到了这个问题,

    但是高手们并没有搭理他们。我决定当这个好为人师的嫌人。

    关于Argo的介绍我这里就不写了,相信能看到这篇文章的人都是循着搜索引擎来的。直接入正题。

    首先:进入..Argocore目录,执行mvn package

    这里会Build 58.com argo 1.0.0生成 ..Argocore argetargo-1.0.0.jar

    然后,将该包加入本地M2仓库.

    执行mvn install:install-file -DgroupId=com.bj58.spat -DartifactId=argo -Dversion=1.0.0 -Dpackaging=jar -Dfile=D:Argocore argetargo-1.0.0.jar

    现在进入..Argosampleshello-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,让项目运行起来

    [INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ argo-
    hello-world ---
    [INFO] Compiling 8 source files to D:Argosampleshello-world	arget	est-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:Argosampleshello-world
    srcmainwebapp
    [INFO] Reload Mechanic: automatic
    [INFO] Classes = D:Argosampleshello-world	argetclasses
    [INFO] Context path = /
    [INFO] Tmp directory = D:Argosampleshello-world	arget	mp
    [INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml
    [INFO] Web overrides =  none
    [INFO] web.xml file = null
    [INFO] Webapp directory = D:Argosampleshello-worldsrcmainwebapp
    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参数
    文件上传展示
    

      

     

     
  • 相关阅读:
    将指定目录的所有文件及文件夹copy到指定目录下,只copy 7天内创建的或是7天内修改过的
    修复置疑态状态的数据库 重建数据库日志
    修改MYSQL最大连接数的3种方法
    [转载]RRDTool 中文手册简易入门(二)
    [转载]RRDTool 快速学习思维导图
    sql server 2008 新功能创建压缩表和索引
    分析src=http://s.see9.us/s.js>亦或3b3.org注入攻击及解决方案探讨....
    创建login帐号及为其添加安全权限
    计数排序 Counting Sort
    基数排序 Radix sort
  • 原文地址:https://www.cnblogs.com/mignet/p/58_argo_build.html
Copyright © 2011-2022 走看看