为什么WTP插件将一个Maven依赖项部署为文件夹,而不是一个jar? [英] Why does the WTP plugin deploy one Maven dependency as a folder, instead of a jar?

查看:125
本文介绍了为什么WTP插件将一个Maven依赖项部署为文件夹,而不是一个jar?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常奇怪的问题与Maven和Eclipse WTP。我有一个多模块项目,让我们称之为项目。它由两个模块 project-base project-web 组成。我已经启用了工作区解析(并且与其他几个很相似的Maven项目一起工作)。



project-base project-web 的依赖,它通常被部署为一个jar文件。但是几天之后,它仍然被部署为我的本地Tomcat中的类文件夹,如下所示:



因此,我的Tomcat不会识别我的任何类文件,因为它希望它们是jar,不是文件夹。
-tests 后缀来自于需要在我的Web项目中从基础测试。我不认为这是问题。



project-web 从工作区中解析出三个依赖关系。其中两个被正确部署为jar,但第三个不是。



project-base pom.xml如下所示:

 < project xmlns =http://maven.apache.org/POM/4.0 .0xmlns: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>
< parent>
< artifactId> project< / artifactId>
< groupId> com.company.project< / groupId>
< version> 4.0.0< / version>
< / parent>
< artifactId> project-base< / artifactId>
< name> projectBase< / name>
< packaging> jar< / packaging>

< properties>
< project.build.sourceEncoding> windows-1251< /project.build.sourceEncoding>
< / properties>

< build>
< plugins>
< plugin>
< groupId> org.apache.maven.plugins< / groupId>
< artifactId> maven-jar-plugin< / artifactId>
< version> 2.3.2< / version>
<执行>
< execution>
< goals>
< goal> jar< / goal>
< goal> test-jar< / goal>
< / goals>
< / execution>
< / executions>
< / plugin>
< plugin>
< artifactId> maven-compiler-plugin< / artifactId>
< configuration>
< source> 1.6< / source>
< target> 1.6< / target>
< / configuration>
< / plugin>
< plugin>
< groupId> org.apache.maven.plugins< / groupId>
< artifactId> maven-site-plugin< / artifactId>
< version> 3.0< / version>
< / plugin>
< plugin>
< groupId> org.apache.maven.plugins< / groupId>
< artifactId> maven-project-info-reports-plugin< / artifactId>
< version> 2.4< / version>
< / plugin>
< / plugins>
< / build>
< / project>

依赖关系 project-base project-web 中定义如下:

 < dependency> 
< groupId> com.company.project< / groupId>
< artifactId> project-base< / artifactId>
< version> $ {project.version}< / version>
< / dependency>

<依赖关系>
< groupId> com.company.project< / groupId>
< artifactId> project-base< / artifactId>
< version> $ {project.version}< / version>
< type> test-jar< / type>
< scope> test< / scope>
< / dependency>

我不知道为什么一个依赖关系以这样一种奇怪的方式部署,知道如何解决这个问题。我清理了项目,tomcat,重新部署了Web项目,清理了我的整个Maven仓库,从VCS检出了整个项目,没有任何帮助。



什么可能导致Eclipse WTP将此依赖项部署为文件夹而不是jar文件?

解决方案

我最终解决了我的问题: project-base 项目的属性部分部署程序集。我不能保存它,如Eclipse所提到的,当前页面确实包含错误。



然后我查看了设置文件 .settings / org。 eclipse.wst.common.component 。这是完全空的(我不知道为什么)。然后我添加了以下块:

 <?xml version =1.0encoding =UTF-8?> 
< project-modules id =moduleCoreIdproject-version =1.5.0>
< wb-module deploy-name =project-base>
< wb-resource deploy-path =/source-path =/ src / main / java/>
< wb-resource deploy-path =/source-path =/ src / main / resources/>
< / wb-module>
< / project-modules>

此后,可以再次访问设置页面,并正确组合JAR。工作区分辨率也可以。


I have a very strange problem with Maven and the Eclipse WTP. I have a multi-module project, let's call it project. It consists of two modules project-base and project-web. I have the workspace resolution enabled (and it works fine with several other very similar Maven projects).

project-base is a dependency of project-web and it's normally deployed as a jar file. But for several days, it keeps being deployed as a class folder in my local Tomcat, as you can see here:

Therefore, my Tomcat does not recognize any of my class files in there, because it expects them to be jars, not folder. The -tests suffix comes from the need to have the test from base in my web project. I don't think this is the problem.

project-web has three dependencies being resolved from the workspace. Two of them are deployed correctly, as jar, but the third one is not.

project-base's pom.xml is shown here:

<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>
    <parent>
        <artifactId>project</artifactId>
        <groupId>com.company.project</groupId>
        <version>4.0.0</version>
    </parent>
    <artifactId>project-base</artifactId>
    <name>projectBase</name>
    <packaging>jar</packaging>

    <properties>
        <project.build.sourceEncoding>windows-1251</project.build.sourceEncoding>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.3.2</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>jar</goal>
                            <goal>test-jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-site-plugin</artifactId>
                <version>3.0</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-project-info-reports-plugin</artifactId>
                <version>2.4</version>
            </plugin>
        </plugins>
    </build>
</project>

The dependency project-base as it is defined in project-web looks like this:

<dependency>
    <groupId>com.company.project</groupId>
    <artifactId>project-base</artifactId>
    <version>${project.version}</version>
</dependency>

<dependency>
    <groupId>com.company.project</groupId>
    <artifactId>project-base</artifactId>
    <version>${project.version}</version>
    <type>test-jar</type>
    <scope>test</scope>
</dependency>

I don't have an idea why one dependency is deployed in such a strange way and I don't know how to fix this. I cleaned the projects, the tomcat, redeployed the web project, purged my whole Maven repository, checked out the whole project fresh from VCS, nothing helped.

What could cause Eclipse WTP to deploy this dependency as a folder instead of a jar file?

解决方案

I ultimately solved my problem: I had problems with the properties section Deployment Assembly for the project-base project. I could not save it, as Eclipse mentioned, the current page does contain errors.

I then looked into the settings file .settings/org.eclipse.wst.common.component. It was completely empty (I don't know why). I then added the following block:

<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
    <wb-module deploy-name="project-base">
        <wb-resource deploy-path="/" source-path="/src/main/java"/>
        <wb-resource deploy-path="/" source-path="/src/main/resources"/>
    </wb-module>
</project-modules>

After this, the settings page is accessible again and the JAR is assembled correctly. Workspace resolution does work, too.

这篇关于为什么WTP插件将一个Maven依赖项部署为文件夹,而不是一个jar?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆