首页 \ 问答 \ Eclipse Maven WTP插件在切换配置文件时没有刷新资源(Eclipse Maven WTP plugin not refreshing resources when switching profile)

Eclipse Maven WTP插件在切换配置文件时没有刷新资源(Eclipse Maven WTP plugin not refreshing resources when switching profile)

我正在使用Eclipse Juno和Maven-WTP插件开发Web应用程序。 这个应用程序有一个标题图像,我也有两个Maven配置文件。 这些配置文件允许更改标题图像,因为它们指向图像所在的不同目录。 这就是它们的配置方式:

<profile>
    <id>local</id>
    <properties>
        <imagen.cabecera.dir>src/main/resources/styles/headers/example1</imagen.cabecera.dir>
    </properties>
</profile>

<profile>
    <id>local2</id>
    <properties>
        <imagen.cabecera.dir>src/main/resources/styles/headers/example2</imagen.cabecera.dir>
    </properties>
</profile>

我的想法是当我更改.m2 / settings.xml中的活动配置文件时,也改变了头文件。 活动配置文件的配置如下:

<activeProfiles>
    <!--make the profile active all the time -->
    <activeProfile>nexus</activeProfile>
    <activeProfile>local</activeProfile>
</activeProfiles>

如果我更改活动配置文件并执行mvn clean install所有内容都像项目目标目录中的charm一样。 但是,问题来自Maven-WTP插件。 这个插件从webapp/images目录获取文件,看起来当我更改活动配置文件时没有获得新的。 似乎WTP插件没有在这里更新文件,所以我得到了旧的一个显示在浏览器中,即使我做了一个clean install 。 这是我的pom.xml配置:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <executions>
        <execution>
            <id>copy-resources</id>
            <phase>process-resources</phase>
            <goals>
                <goal>copy-resources</goal>
            </goals>
            <configuration>
                <outputDirectory>${project.build.directory}</outputDirectory>
                <resources>
                    <resource>
                        <directory>${imagen.cabecera.dir}</directory>
                        <includes>
                            <include>cabecera.jpg</include>
                        </includes>
                        <targetPath>${project.build.directory}/header</targetPath>
                    </resource>
                </resources>
            </configuration>
        </execution>
    </executions>
</plugin>

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <executions>
        <execution>
            <id>default-war</id>
            <configuration>
                <webResources>
                    <resource>
                        <directory>${project.build.directory}/header</directory>
                        <includes>
                            <include>cabecera.jpg</include>
                        </includes>
                        <targetPath>/images</targetPath>
                    </resource>
                </webResources>
            </configuration>
        </execution>
    </executions>
</plugin>

有人知道吗?


I'm developing a web application using Eclipse Juno and Maven-WTP plugin. This application has a header image and I also have two Maven profiles. Those profiles permit changing the header image, because they point to a different directory, where the image is located. That's how they are configured:

<profile>
    <id>local</id>
    <properties>
        <imagen.cabecera.dir>src/main/resources/styles/headers/example1</imagen.cabecera.dir>
    </properties>
</profile>

<profile>
    <id>local2</id>
    <properties>
        <imagen.cabecera.dir>src/main/resources/styles/headers/example2</imagen.cabecera.dir>
    </properties>
</profile>

The idea is when I change the active profile in my .m2/settings.xml to have the header file changed as well. The active profile is configured like that:

<activeProfiles>
    <!--make the profile active all the time -->
    <activeProfile>nexus</activeProfile>
    <activeProfile>local</activeProfile>
</activeProfiles>

If I change the active profile and do mvn clean install everything works like a charm in project's target directory. However, the problem comes with Maven-WTP plugin. This plugin is taking the file from webapp/images directory, and looks like when I change the active profile is not getting the new one. It seems the WTP plugin is not updating the file here, so I get the old one displayed in the browser, even I do a clean install. This is my pom.xml configuration:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <executions>
        <execution>
            <id>copy-resources</id>
            <phase>process-resources</phase>
            <goals>
                <goal>copy-resources</goal>
            </goals>
            <configuration>
                <outputDirectory>${project.build.directory}</outputDirectory>
                <resources>
                    <resource>
                        <directory>${imagen.cabecera.dir}</directory>
                        <includes>
                            <include>cabecera.jpg</include>
                        </includes>
                        <targetPath>${project.build.directory}/header</targetPath>
                    </resource>
                </resources>
            </configuration>
        </execution>
    </executions>
</plugin>

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <executions>
        <execution>
            <id>default-war</id>
            <configuration>
                <webResources>
                    <resource>
                        <directory>${project.build.directory}/header</directory>
                        <includes>
                            <include>cabecera.jpg</include>
                        </includes>
                        <targetPath>/images</targetPath>
                    </resource>
                </webResources>
            </configuration>
        </execution>
    </executions>
</plugin>

Does anybody know about that?


原文:https://stackoverflow.com/questions/14316856
更新时间:2019-12-03 08:12

最满意答案

您可能需要通过以下方式更新Maven项目配置:

右键单击您的项目 - > Maven - >更新项目

在此处输入图像描述


The Maven Eclipse WTP Plugin is getting the data to deploy from webapp directory. The clue is that this directory is not being cleaned when executing mvn clean install, because Maven only cleans target directory. The trick is forcing Maven to clean the resources I'm going to update too.

<plugin>
    <artifactId>maven-clean-plugin</artifactId>
    <version>2.5</version>
    <configuration>
        <filesets>
            <fileset>
                <directory>src/main/webapp/images</directory>
                <includes>
                    <include>cabecera.jpg</include>
                </includes>
            </fileset>
        </filesets>
    </configuration>
</plugin>
2017-05-23

相关问答

更多

如果没有注释,Rust无法推断类型(Rust cannot infer type without annotation)

问题是MyHashGenerator没有采用类型参数。 所以你做了一个承诺“ 相同的类型MyHashGenerator就足以作为一个哈希生成器,并且无论T如何都会以完全相同的方式运行”。 self.hash("")是对HashGenerator hash调用,但Rust并不一定知道它与 HashGenerator实例相同 。 您可以通过以下两种方式之一明确说明此要求。 选项1:显式类型参数 通过明确告诉Rust参数是什么,可以避免这个问题。 fn hash_node(&self) -> u64

数学计算 - 浮点数[重复](Math Calculation - float numbers [duplicate])

你应该这样做 float years = (1.0/31536000.0) * 883102.00; 要么 float years = (1.0/31536000) * 883102.00; 可能也会有效。 您的第一个数字被视为整数。 You should instead do float years = (1.0/31536000.0) * 883102.00; or float years = (1.0/31536000) * 883102.00; might work as wel

如何阻止iOS键盘干扰UITextField位置(How to stop iOS keyboard interfering with UITextField position)

替换您的代码如下:希望它现在可以工作 搜索按钮: - (IBAction)searchButton:(id)sender { //[UITextField commitAnimations]; [UIView animateWithDuration:0.5 animations:^{ _enterRoomLabel.hidden = YES; [_srcButton setHidden:YES]; [_srcAgainButton

每个模块的Maven java版本(Maven java version per module)

是的,这是支持的。 对于每个模块,在Maven中,您需要指定正确的编译器源和目标版本。 当你在IntelliJ中导入它时,它会知道。 我相信Eclipse也能解决它。 Yes, this is supported. For each module, in Maven you need to specify the proper compiler source and target versions. When you import it in IntelliJ it will know. I'm

c ++流负数转换(c++ stream negative number conversion)

int32_t cint; cint = strtol(ss.str().c_str(), NULL, 0); 这将值0xffffffff读取为long ,然后将其转换为int32_t 。 如果long大于32位,则strtol工作并返回0xffffffff即4294967295,将其转换为int32_t会产生-1。 但这与从字符串中读取负数不同(如果long为32位,则它不能按预期工作,而是返回LONG_MAX并将其转换为int32_t ,即0x7fffffff )。 int32_t cpp

添加资源和设置Exe描述[重复](Adding resources and setting Exe description [duplicate])

看看我的朋友。 我认为这会让你感到厌烦,因为这个人有同样的问题: 我们如何将嵌入式资源添加到在运行时从源文件编译的文件中 Have a look here my friend. I think this will sort you out as the guy was having the very same issue: How can we add embedded resources to a file which is compiled from a source file at run

改进MS Project VB / VBA任务创建(improving MS Project VB/VBA task creation)

额外任务的问题可以通过存储所选任务的集合(或.net中的列表)然后循环遍历这些任务来解决。 我在VBA中发布解决方案,因为这可能与其他观众最相关; 如果需要,我可以发布一个vb.net版本。 Application.ScreenUpdating = False Dim proj As Project Set proj = Application.ActiveProject Dim myTask As Task Dim colTasks As New Collection For Each m

Keras替换输入层(Keras replacing input layer)

使用以下方法保存模型时: old_model.save('my_model.h5') 它会节省以下内容: 模型的体系结构,允许创建模型。 模型的权重。 模型的训练配置(丢失,优化器)。 优化器的状态,允许训练从您之前离开的地方恢复。 那么,当你加载模型时: res50_model = load_model('my_model.h5') 你应该得到相同的型号,你可以使用以下方法验证相同: res50_model.summary() res50_model.get_weights() 现在您可

相关文章

更多

最新问答

更多
  • 根据Woocommerce中的自定义字段计算自定义购物车商品价格(Custom cart item price calculation based on dimentions custom fields in Woocommerce)
  • 分开foreach项目并单独打印(Separate foreach items and print them individually)
  • 写模式管道是否同步?(Is write mode pipe synchronous?)
  • 发现可用的Windows Phone强调色和本地化名称(Discover available Windows Phone accent colors and localized names)
  • 使用多线程和WPF更新集合(Update Collection with multithreading and WPF)
  • 如何在字符串的情况下使用同步?(How should the synchronization be used in case of strings?)
  • 打印唯一的行,比较不超过N个字符(Print unique lines, compare no more than N characters)
  • Javascript / jQuery - 如何调用switch case从另一个函数执行(Javascript/jQuery - how to call a switch case to execute from another function)
  • Hbase超时错误不断发生(Hbase timeout errors keep occuring)
  • 如何在Delphi中更改TabControl中活动TAB的颜色(How to change the color of active TAB in a TabControl, in Delphi)
  • 正则表达式:在sublime文本中替换一些PHP代码(Regex: replace some pieces of php code in sublime text)
  • 在带有Scene2D的LibGDX中,如何在按下按钮时连续向右走?(In LibGDX with Scene2D, how can I continuously walk to the right when a button is pressed?)
  • 累加器如何在Haskell中工作?(How do accumulators work in Haskell?)
  • 使用开关检查市场和前缀与正确的货币符号(using switch to check market and prefix with correct currency symbol)
  • 在哪里分配一次使用类?(Where to allocate one time use class?)
  • 如何从两个DateTime / NaiveDateTime获取持续时间?(How do I get Duration from two DateTime / NaiveDateTime?)
  • 解析TimeSpan大于24小时?(Parse a TimeSpan greater than 24 hours? [duplicate])
  • 如何在球拍中本地更改阅读规则?(How to locally change reading rules in racket?)
  • 数据库应该由DI注入时的模拟存储(通过构造函数)(Mock storage when database should be injected by DI (through constructor))
  • 使用maven集成2个eclipse项目(Integrate 2 eclipse projects using maven)
  • 角度ng-repeat不检测变化(Angular ng-repeat not detecting changes)
  • Xaml组件在Silverlight + XNA应用程序的多个页面中可见(Xaml component visible in multiple pages in Silverlight+XNA applications)
  • 如何将`var`变量等同于另一个查询(How to equate `var` variable to another query)
  • 如何设计hyperledger链代码以适合您的业务?(how to design your chaincode of hyperledger to fit for your business?)
  • PHP readfile错误(PHP readfile error)
  • 在Date之后排序列表然后是时间(Sorting list after Date then time)
  • Android内部版本号(Android build number)
  • 在没有预设退出条件的情况下停止无限循环(stopping an infinite loop with no preset exit condition)
  • Phonegap应用程序全屏通过html页面中的按钮(Phonegap Application fullscreen through a button in html page)
  • PAA是否适合在门户网站中自动执行wcm库部署和设置?(Is PAA a good candidate for automating wcm library deployment and setup in portal?)