java - Java War 文件不会在 Eclipse 中使用 WildFly 更新
问题描述
我在 Windows 7 64 位上使用 Eclipse 版本 2019-03 (4.11.0) 和 Wildfly 16。我已经在 Eclipse 中将我的 Java Web 项目转换为 Maven 项目。通过向导进行的初始配置和部署有效,但现在每当我更改我的代码并尝试重新部署时,我都看不到更新的代码。到目前为止我所尝试的(我实际上不确定如何进行重新部署,并假设以下一项或多项组合会强制重新部署):
- 更新项目(Alt + F5 并右键单击项目 --> Maven --> 更新项目)
mvn clean
mvn install
mvn clean install
- 更新项目,然后
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>
编辑:我更新了问题以澄清我实际上不确定如何重新部署。
解决方案
实际上,您上面列出的所有选项都不会重新部署应用程序。
- 更新项目:修改 Eclipse 项目以从 pom.xml 中获取更改
mvn clean install
(来自 CLI):运行 Maven(在 Eclipse 之外),清理目标目录,将所有源代码编译到目标目录,打包 .war 文件,将其安装在本地 .m2 存储库中。通常你根本不需要这个,只需从菜单中选择“自动构建”。
我想您已经在 Eclipse 的“服务器”视图中配置了 Wildfly。如果您想重新部署,您应该在该视图中找到某种“重新启动”和/或“重新部署”命令。
推荐阅读
- java - 如何在内部 pojo 类上应用 javax 自定义验证?
- python - 如何将大列表细分为子列表并使用它们创建新列表
- cplex - 在解决方案池 Cplex 中保留唯一值
- mysql - JOOQ:使用 one2one 关系更新两个表
- c++ - 如何诠释。并且float会影响代码ex(1.3-1)* 10,为什么将该值存储在float中会在存储在int中时给出不同的值?
- android - Stripe Android - 扫描卡
- php - 如何使用 Laravel 的代理库?
- java - 当池大小为 1 时,ScheduledExecutorService 是否保证顺序?
- android - React Native Firebase - 一段时间后不会出现 Android 10 通知
- xml - Apache Camel XSLT:如何在导入中使用 xsl 模板?