我是Maven初学者,经过一些反复试验,我设法为发布WAR指定了与开发WAR相关的不同属性文件(我试图以我能想到的最简单的方式进行,但可以随意建议任何更简单的解决方案)。
因此,在开发过程中,我的database.properties
和log4j.properties
来自src/main/Resources
,而产生的发行版WAR它们来自src/main/Resources
。
到目前为止,一切顺利。
问题是:既然我在使用Eclipse,那么在POM中有没有一种方法可以说src/main/resources/release也是一个源文件夹,这样Eclipse就可以将其列在项目浏览器中的其他源文件夹下,即使其他开发人员在IDE中导入项目(即不手动将该文件夹添加为源文件夹)?
这是我的POM的相关部分:
<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>
...
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<war-name>/</war-name>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
...
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
...
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
...
</plugin>
</plugins>
</build>
<dependencies> ... </dependencies>
<profiles>
<profile>
<id>release</id>
<properties>
<war-name>ROOT</war-name>
</properties>
<build>
<resources><!-- Replace Maven default resources directory (this could probably be achieved with a property)-->
<resource>
<filtering>true</filtering>
<directory>${basedir}/src/main/resources/release</directory>
<includes>
<include>*</include>
</includes>
</resource>
</resources>
</build>
</profile>
</profiles>
我是这样做的。
基本上,我在默认配置中声明了我想在Eclipse中看到的所有资源文件夹(在每个概要文件中添加它们并不起作用,因为当概要文件处于活动状态时
当然,我们非常感谢您的任何评论!
<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>...</groupId>
<artifactId>...</artifactId>
<version>...</version>
<packaging>war</packaging>
<name>...</name>
<!-- My prerequisite was that when working in Eclipse no extra steps
should be required to make the IDE use the right configuration than
Configure -> Convert to Maven Project, so I didn't like having
default settings in a profile that must be enabled in Eclipse project
configuration -->
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<war-name>/</war-name>
<!-- These solve the problem: AFAICT, each <resource /> is added to the final POM,
so declaring a resources folder in a profile didn't exclude other resources
folders declared in the default (i.e. without profiles active) configuration.
So, the solution is to change what Maven brings in from each folder depending
on the profile currently active. What follows is the default, no-profile
active configuration. -->
<res.devel.includes>**/*</res.devel.includes>
<res.devel.excludes></res.devel.excludes>
<res.local.includes></res.local.includes>
<res.local.excludes>*</res.local.excludes>
<res.release.includes></res.release.includes>
<res.release.excludes>*</res.release.excludes>
</properties>
<build>
<resources><!-- Here I declare all the resources folders, so that they will all be shown in Eclipse. Property values drive what is included and excluded. -->
<resource><!-- This is the default Maven main resource directory -->
<directory>${basedir}/src/main/resources-local</directory>
<filtering>true</filtering>
<includes>
<include>${res.devel.includes}</include>
</includes>
<excludes>
<exclude>${res.devel.excludes}</exclude>
</excludes>
</resource>
<resource><!-- This is the resources directory for when the WAR is deployed on a local standalone Tomcan installation (useful for web pages editing) -->
<directory>${basedir}/src/main/resources-local</directory>
<filtering>true</filtering>
<includes>
<include>${res.local.includes}</include>
</includes>
<excludes>
<exclude>${res.local.excludes}</exclude>
</excludes>
</resource>
<resource><!-- This is the resource directory for when the WAR will be deployed -->
<directory>${basedir}/src/main/resources-release</directory>
<filtering>true</filtering>
<includes>
<include>${res.release.includes}</include>
</includes>
<excludes>
<exclude>${res.release.excludes}</exclude>
</excludes>
</resource>
</resources>
<plugins>
<!-- Plugins configurations -->
</plugins>
</build>
<dependencies>
<!-- Dependencies declarations -->
</dependencies>
<profiles><!-- Here are the profiles. When working in Eclipse no profile is active, so the resources will be taken only from src/main/resources (as per default properties values). -->
<profile>
<id>local</id><!-- This is for when the WAR is deployed on a local standalone Tomcat instance (i.e. outside of Eclipse) -->
<properties>
<war-name>ROOT</war-name>
<!-- The resources will be taken only from src/main/resources-local -->
<res.devel.includes></res.devel.includes>
<res.devel.excludes>*</res.devel.excludes>
<res.local.includes>*</res.local.includes>
<res.local.excludes></res.local.excludes>
<res.release.includes></res.release.includes>
<res.release.excludes>*</res.release.excludes>
</properties>
</profile>
<profile>
<id>release</id><!-- This is for when the WAR is deployed on the production server -->
<properties>
<war-name>ROOT</war-name>
<!-- The resources will be taken only from src/main/resources-release -->
<res.devel.includes></res.devel.includes>
<res.devel.excludes>*</res.devel.excludes>
<res.local.includes></res.local.includes>
<res.local.excludes>*</res.local.excludes>
<res.release.includes>*</res.release.includes>
<res.release.excludes></res.release.excludes>
</properties>
</profile>
</profiles>
</project>
您可以指定eclipse应该在...
右键单击项目,选择Maven,并包含您可以eclipse以在其下工作的配置文件。
当您执行maven更新项目时(即eclipse应该识别新的源文件夹),一旦您更改了配置文件,您的配置文件应该由eclipse获取。
<build>
...
< sourceDirectory > src/main/java </ sourceDirectory >
< testSourceDirectory > src/test/java </ testSourceDirectory >
< resources >
< resource >
< directory > src/main/resources </ directory >
</ resource >
</ resources >
< testResources >
< testResource >
< directory > src/test/resources </ directory >
</ testResource >
</ testResources >
...
</build>
问题内容: 我是Maven初学者,经过反复试验,我设法为WAR发行版相对于开发WAR指定了不同的属性文件(我尝试用我能想到的最简单的方法来做,但是可以建议任何更简单的解决方案)。 因此,在开发过程中,my 和来自,同时生成它们来自的发布WAR 。 到目前为止,一切都很好。 现在的问题是:因为我与Eclipse的工作,有没有办法说,里面的,那是一个源文件夹也使Eclipse将列出它在Project
我在一个文件夹中有一个robot资源文件,并且希望在执行Maven安装时同时包含该文件夹和robot资源文件。 项目>src>main>java... 在我的pom.xml文件中,我添加了: 当我执行Maven install时,我只看到jar中的robot资源文件,而看不到它的文件夹。我如何使它使机器人资源文件在文件夹内?我是Maven的新手,所以我希望得到任何指导。我看过这篇文章,但这篇文章没
Marcin Grzejszczak谈论Spring Cloud Sleuth和Zipkin 点击此处查看视频
资源(Asset)代表 source 文件夹中除了文章以外的所有文件,例如图片、CSS、JS 文件等。比方说,如果你的Hexo项目中只有少量图片,那最简单的方法就是将它们放在 source/images 文件夹中。然后通过类似于 ![](/images/image.jpg) 的方法访问它们。 对于那些想要更有规律地提供图片和其他资源以及想要将他们的资源分布在各个文章上的人来说,Hexo也提供了更组
我在我的pom中复制并粘贴了以下取自文档的片段。xml 但当我尝试触发部署时,会收到以下消息: 这是我的目录结构: 如何更改资源的目标文件夹?为什么maven没有解析插件中的配置指令?
如何在maven pom文件中定义源文件夹顺序?我目前使用的是标准的maven目录布局,但每当我运行命令“mvn eclipse:eclipse”时,源文件夹顺序如下: src/test/java src/test/Resources src/main/java src/main/Resources 如何将其设置为: src/main/java src/main/resources src/tes