简体   繁体   中英

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.

<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:

<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.

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.

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.

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. You could try adding the appropriate M2E connector (assuming you have already installed Maven Integration for Eclipse).

The m2e-wtp connector ( https://www.eclipse.org/m2e-wtp/ ) looks like it does what you need. You can install it from the Eclipse Marketplace (or it ships by default with some versions of Eclipse).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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