Java War文件将无法在带有WildFly的Eclipse中更新

时间:2019-05-30 13:46:09

标签: java eclipse maven

我在Windows 7 64位上使用Eclipse版本2019-03(4.11.0)和Wildfly 16。我已经将Java Web Project转换为Eclipse中的Maven项目。可以通过向导进行初始配置和部署,但是现在无论何时我更改代码并尝试重新部署,都不会看到更新的代码。到目前为止,我已经尝试过(我实际上不确定如何进行重新部署,并假设以下一项或多项措施将强制进行重新部署):

  1. 更新项目(Alt + F5并右键单击项目-> Maven->更新项目)
  2. mvn clean
  3. mvn install
  4. mvn clean install
  5. 更新项目,后跟mvn clean install

这是我的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>com.example</groupId>
  <artifactId>GumboChannel</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
  <name>GumboChannel</name>
  <description></description>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <resources>
      <resource>
        <directory>src</directory>
        <excludes>
          <exclude>**/*.java</exclude>
        </excludes>
      </resource>
    </resources>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.0</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>3.2.1</version>
        <configuration>
          <warSourceDirectory>WebContent</warSourceDirectory>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <dependencies>
  <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-core</artifactId>
    <version>2.9.9</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations -->
<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-annotations</artifactId>
    <version>2.9.9</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>2.9.9</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.servlet/jstl -->
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>jstl</artifactId>
    <version>1.2</version>
</dependency>

<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.1.0</version>
    <scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>5.4.2.Final</version>
</dependency>
  </dependencies>
</project>

编辑:我更新了问题以明确说明我实际上不确定如何重新部署。

1 个答案:

答案 0 :(得分:0)

实际上,您上面列出的所有选项都没有重新部署应用程序。

  • 更新项目:修改Eclipse项目以从pom.xml中进行更改
  • mvn clean install(来自CLI):运行Maven(在Eclipse外部),清理目标目录,将所有源代码编译到目标目录,打包.war文件,然后将其安装在本地.m2存储库中。通常,您根本不需要这些,只需从菜单中选择“自动构建”即可。

我想您已经在Eclipse的“服务器”视图中配置了Wildfly。如果要重新部署,则应该在该视图中找到某种“重新启动”和/或“重新部署”命令。