简体   繁体   English

Eclipse Tomcat可以自动在公共项目中拾取添加的文件吗?

[英]Can Eclipse Tomcat automatically pick up added files in common project?

When put some share configuration files in services-common project, we exclude it from the jar. 当将一些共享配置文件放入“服务”公共项目中时,我们将其从jar中排除。

<build>
<resources>
    <resource>
        <directory>src/main/resources</directory>
        <excludes>
            <exclude>**</exclude>
        </excludes>
        <filtering>false</filtering>
    </resource>
</resources>
</build>

and in other projects(rest or ui) we use maven-war-plugin to include files from /services-commons/src/main/resources like below: 在其他项目(rest或ui)中,我们使用maven-war-plugin包含来自/ services-commons / src / main / resources的文件,如下所示:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
    <webResources>
        <resource>
            <targetPath>WEB-INF/classes</targetPath>
            <directory>../services-commons/src/main/resources</directory>
        </resource>
    </webResources>
</configuration>
</plugin>

This works when we use maven to build in command line. 当我们使用maven在命令行中构建时,此方法有效。

But when we add a new file in /services-commons/src/main/resources, we will have to run maven clean install in command line, and run tomcat clean, otherwise tomcat will not pick up the newly added file. 但是,当我们在/ services-commons / src / main / resources中添加新文件时,我们将必须在命令行中运行maven clean install,并运行tomcat clean,否则tomcat将不会拾取新添加的文件。

This is cumbersome, so I am wondering whether there is better way: we can put share common file in one project, eclipse tomcat can automatically pick up new file added in common project. 这很麻烦,所以我想知道是否有更好的方法:我们可以将共享公用文件放在一个项目中,eclipse tomcat可以自动提取在公用项目中添加的新文件。

Your problem here is that Eclipse does not recognise that part of your POM, so that part is only being executed when you run maven from the command line. 您的问题是Eclipse无法识别POM的那部分,因此仅当您从命令行运行maven时才执行该部分。 You could try adding the appropriate M2E connector (assuming you have already installed Maven Integration for Eclipse). 您可以尝试添加适当的M2E连接器(假设您已经安装了Maven Integration for Eclipse)。

The m2e-wtp connector ( https://www.eclipse.org/m2e-wtp/ ) looks like it does what you need. m2e-wtp连接器( https://www.eclipse.org/m2e-wtp/ )看起来像您所需要的。 You can install it from the Eclipse Marketplace (or it ships by default with some versions of Eclipse). 您可以从Eclipse Marketplace中安装它(或者它在某些版本的Eclipse中默认提供)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM