【问题标题】:Web service maven build jar does not workWeb服务maven构建jar不起作用
【发布时间】:2017-09-10 18:40:51
【问题描述】:

我想在 jar 中构建一个可以部署在 JBoss 服务器上的 Web 服务项目。如果我编译一个.war 项目,这可以做到这一点,它用这个内容制作了 12Mo

但是在我的 pom.xml 中,当我想指定我想要一个 .jar 项目时,我得到了一个档案,它制作了 10Ko,并且几乎没有像这张图片这样的内容

这是我的 pom.xml 文件

<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">
<modelVersion>4.0.0</modelVersion>
<groupId>MonWebServiceFacility</groupId>
<artifactId>MonWebServiceFacility</artifactId>
<version>0.0.1-SNAPSHOT</version>
<!--<packaging>war</packaging>-->
<build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.5.1</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
    </plugins>
</build>
<properties>
    <cxf.version>3.1.7</cxf.version>
</properties>
<dependencies>
    ...SOME DEPENENCIES...
</dependencies>

那么我如何构建 jar 存档以部署在我的 JBoss 服务器中?

这是我的项目架构:

【问题讨论】:

    标签: eclipse web-services maven jar pom.xml


    【解决方案1】:

    你需要在 pom.xml 中使用&lt;packaging&gt;jar&lt;/packaging&gt;,还需要在 webaap>WEB_INF 文件夹中创建 web.xml。

    <servlet>
    <servlet-name>myServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:ApplicationContext.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
    

    <servlet-mapping>
        <servlet-name>myServlet</servlet-name>
        <url-pattern>/api/*</url-pattern>
    </servlet-mapping>
    
    <filter>
        <filter-name>encoding-filter</filter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
        <init-param>
            <param-name>forceEncoding</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>
    
     <filter-mapping>
        <filter-name>encoding-filter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    
    <welcome-file-list>
        <welcome-file>/index.jsp</welcome-file>
    </welcome-file-list>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-05-28
      • 1970-01-01
      • 1970-01-01
      • 2016-09-02
      • 1970-01-01
      • 2013-06-13
      • 2021-06-06
      • 1970-01-01
      相关资源
      最近更新 更多