Web resources filtering with Maven war plugin does not work in Eclipse with m2e

后端 未结 6 1673
感情败类
感情败类 2021-01-30 14:37

I\'m trying to filter a Spring configuration file using Maven filtering. My POM is configured like this:

        ...
        
          

        
6条回答
  •  别那么骄傲
    2021-01-30 14:59

    Well, finally I got it.

    First of all, I did what khmarbaise pointed out. I moved applicationContext.xml to the resources folder. War plugin webResources are meant to work with external resources, and filtering a file in the destination folder itself was not the best practice. I updated the POM to reflect the new configuration

        
            
                src/main/resources
                true
            
        
    

    and

            
                org.apache.maven.plugins
                maven-war-plugin
                2.2
                
                    
                        
                            true
                            WEB-INF/context
                            src/main/resources/WEB-INF/context
                            
                                applicationContext.xml
                            
                        
                    
                
            
    

    So, half of the credit to him. But that's was not enough, it still didn't work. I realized that Maven/m2e was indeed filtering my file, but it didn't get my defined properties files. After some testing I found out that m2e is ignoring the activeByDefault option in the profiles activation section.

    So, I added my default profile to the project Maven configuration and then it worked

    enter image description here

提交回复
热议问题