gpt4 book ai didi

java - Maven 命令行中的 Java Build Path 模拟是什么?

转载 作者:行者123 更新时间:2023-11-28 23:30:06 25 4
gpt4 key购买 nike

我正在尝试从 Maven 命令行运行一个已经在 Eclipse 中正常运行的项目。当我在 Eclipse 构建路径上有“Apache Tomcat 7.0”时,它可以工作。当我不这样做时,它会失败,并显示它从命令行给出的确切错误。因此,我怀疑这种差异是从命令行运行它所需要的。如果使用 Maven 在命令行上运行,那么在 Eclipse 中将“Apache Tomcat 7.0”添加为目标运行时的等效项是什么?

最佳答案

Eclipse 为你添加了一些东西,如果你想避免这个问题,你必须使用 maven 手动添加所有你需要的东西,在 <build> tag 你可以添加一个名为 <resources> 的标签,在那里你可以手动添加你在 java 构建路径中添加的所有东西,例如:

<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>configProperties/serverContextConfig.properties</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<includes>
<include>**/*.properties</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<includes>
<include>report/documents/*.*</include>
</includes>
</resource>
</resources>
</build>

默认情况下,Maven 会在 src/main/resources 下查找您项目的资源。

Project
|-- pom.xml
`-- src
`-- main
`-- resources

但是,您的所有资源可能不在 src/main/resources 中。因此,您必须通过将以下内容添加到 POM 来指定这些目录。

<project>
...
<build>
...
<resources>
<resource>
<directory>[your folder here]</directory>
</resource>
</resources>
...
</build>
...
</project>

点击here获取更多信息。

关于java - Maven 命令行中的 Java Build Path 模拟是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31617215/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com