【问题标题】:How to create a war file using terminal如何使用终端创建战争文件
【发布时间】:2014-03-22 16:43:12
【问题描述】:

我需要知道如何在 Ubuntu 系统中使用“终端”应用程序创建一个 war 文件。在定义路径/目标文件夹后应该执行哪些命令以及应该遵循哪些步骤

这是我的 POM 文件内容

<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.erp</groupId>
    <artifactId>erp-web</artifactId>
    <packaging>war</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>erp-web Maven Webapp</name>
    <url>http://maven.apache.org</url>

    <!-- Shared version number properties -->
    <properties>
        <org.springframework.version>3.0.5.RELEASE</org.springframework.version>
    </properties>

    <dependencies>
        <!-- Backend API project -->
        <dependency>
            <groupId>com.erp</groupId>
            <artifactId>erp</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.0.1</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.tiles</groupId>
            <artifactId>tiles-jsp</artifactId>
            <version>2.2.2</version>
        </dependency>

        <dependency>
            <groupId>org.apache.tiles</groupId>
            <artifactId>tiles-servlet</artifactId>
            <version>2.2.2</version>
        </dependency>

        <dependency>
            <groupId>org.apache.tiles</groupId>
            <artifactId>tiles-extras</artifactId>
            <version>2.2.2</version>
        </dependency>

        <!-- Web application development utilities applicable to both Servlet and 
            Portlet Environments (depends on spring-core, spring-beans, spring-context) 
            Define this if you use Spring MVC, or wish to use Struts, JSF, or another 
            web framework with Spring (org.springframework.web.*) -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>

        <!-- Spring MVC for Servlet Environments (depends on spring-core, spring-beans, 
            spring-context, spring-web) Define this if you use Spring MVC with a Servlet 
            Container such as Apache Tomcat (org.springframework.web.servlet.*) -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>

        <!-- Spring MVC for Portlet Environments (depends on spring-core, spring-beans, 
            spring-context, spring-web) Define this if you use Spring MVC with a Portlet 
            Container (org.springframework.web.portlet.*) -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc-portlet</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-web</artifactId>
            <version>3.1.0.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
            <version>3.1.0.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-taglibs</artifactId>
            <version>3.1.0.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.1.2</version>
        </dependency>

        <dependency>
            <groupId>commons-httpclient</groupId>
            <artifactId>commons-httpclient</artifactId>
            <version>3.0</version>
            <exclusions>
                <exclusion>
                    <groupId>commons-codec</groupId>
                    <artifactId>commons-codec</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>

        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
            <version>1.2.1</version>
            <exclusions>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>1.4</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.4.3</version>
        </dependency>
    </dependencies>
    <build>
        <finalName>mycode</finalName>

    </build>
</project>

当我运行 Maven 命令(mvn clean install)时,我得到了这个错误

Missing:
----------
1) com.erp:erp:jar:1.0-SNAPSHOT

  Try downloading the file manually from the project website.

  Then, install it using the command: 
      mvn install:install-file -DgroupId=com.erp -DartifactId=erp -Dversion=1.0-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file

  Alternatively, if you host your own repository you can deploy the file there: 
      mvn deploy:deploy-file -DgroupId=com.erp -DartifactId=erp -Dversion=1.0-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

  Path to dependency: 
    1) com.erp:erp-web:war:1.0-SNAPSHOT
    2) com.erp:erp:jar:1.0-SNAPSHOT

----------
1 required artifact is missing.

for artifact: 
  com.erp:erp-web:war:1.0-SNAPSHOT

from the specified remote repositories:
  central (http://repo1.maven.org/maven2)

【问题讨论】:

  • 你能贴一些代码吗?到目前为止,您尝试过什么?
  • 我尝试运行 Maven 命令(mvn clean install)然后我得到一个错误。它抱怨缺少依赖文件。(1) com.erp:erp:jar:1.0-SNAPSHOT)

标签: eclipse ubuntu terminal pom.xml


【解决方案1】:

在项目路径下,$ jar -cvf YOUR_WAR.war * 应该执行这些操作(在使用 javac 命令编译文件之后),您可以将星号替换为用逗号分隔的自定义文件目标 ,

不过,我强烈建议使用 构建/打包 工具,例如 Apache Maven 或 Ant。 使用 maven,您可以使用 mave-war-plugin 生成 Web 存档,对于 Apache Ant,您可以关注此 war build sample

BR。

【讨论】:

  • 我有这个项目。但问题是我无法运行 Maven 命令。它抱怨缺少文件。(1) com.erp:erp:jar:1.0-SNAPSHOT)
  • 似乎缺少依赖问题,您能发布您的 pom.xml 文件吗?到目前为止您尝试了什么?
  • 您好,我已经复制粘贴了我的 POM 文件内容。请看一下
  • 我尝试下载缺少的依赖,但失败了。它给了我以上错误
【解决方案2】:

我有点担心下面的依赖,因为所有其他的似乎都很熟悉: com.erp erp 1.0-快照 那么这是您自己开发的定制项目吗? 然后你应该将此原型安装到本地存储库中。

【讨论】:

  • 这个项目是别人做的。不幸的是,我和他没有任何联系。你能解释一下我该怎么做吗?在此先感谢...
  • 我试过这个命令(mvn install:install-file)。但它给了我构建错误。我在这里错过了什么..?我按照以下链接中的说明进行操作stackoverflow.com/questions/14406652/…
  • 您有 com.erp 项目的源代码吗?甚至是打包的存档(.jar 文件)?
  • 因此您必须将其安装到本地存储库中:在项目 (com.erp) 根文件夹中使用 $ mvn clean install 命令。您应该会看到类似 [INFO] 将 erp.jar 安装到 $LOCAL_REPO/com/erp/erp.jar 的消息。
  • 嗨,tmarwen。根文件夹是什么意思..我们的项目在桌面上。在我们进入项目文件夹后,它有 SRC、TARGET、文件夹和 POM.xml 文件。所以我们在做什么,我们将路径更改为“cd Desktop/project”并运行了这个 maven 命令(mvn clean install),所以只有我们得到了关于缺少依赖项的错误。我们的路径正确吗?我们是否需要进入“SRC”或“目标”文件夹
猜你喜欢
  • 2010-11-03
  • 1970-01-01
  • 1970-01-01
  • 2021-05-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-08-16
相关资源
最近更新 更多