【发布时间】:2015-10-26 12:55:45
【问题描述】:
我有以下问题:我想使用 maven 配置文件和 maven-war-plugin 来过滤我的 web 应用程序,因此只需单击一下即可将其部署在实时服务器或开发服务器上。
当我通过 Eclipse (Maven-Plugin) 构建 .WAR 存档,然后通过 tomcat-manager-interface 手动将其部署到 tomcat-server 上时,我的应用程序按预期工作。 (在生成的 .WAR-archive 中正确替换了所有变量)
但是当我想使用 Eclipse 的“在服务器上运行” 运行应用程序时,会发生异常:
[..] 嵌套异常是 org.springframework.beans.BeanInstantiationException:无法实例化 bean 类 [org.springframework.security.web.authentication.logout.LogoutFilter]:构造函数抛出异常;嵌套异常是 java.lang.IllegalArgumentException: ${security.casEntryPoint.logoutSuccessUrl} 不是有效的重定向 URL
这是我pom.xml中maven配置文件的配置:
<profiles>
<profile>
<id>prod</id>
<build>
<filters>
<filter>src/main/filters/dfnaaiAgreement-prod.properties</filter>
</filters>
</build>
</profile>
<profile>
<id>devLocal</id>
<build>
<filters>
<filter>src/main/filters/dfnaaiAgreement-devLocal.properties</filter>
</filters>
</build>
</profile>
这是 *.properties 文件的示例条目:
security.casEntryPoint.logoutSuccessUrl = https://example_entry/please_logmeout
这是 settings.xml 中的一项,应替换为 *.properties 文件中的值:
<security:logout logout-url="/logout" logout-success-url="${security.casEntryPoint.logoutSuccessUrl}" />
这是 maven 插件的配置(在 pom.xml 中),用于过滤配置文件:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<warName>dfnaaiAgreement</warName>
<webResources>
<resource>
<directory>${basedir}/src/main/webapp</directory>
<filtering>true</filtering>
<includes>
<include>**/*.xml</include>
<include>**/*.properties</include>
</includes>
</resource>
</webResources>
</configuration>
这是我的 Maven 构建配置:
Maven-Build configuration (Sorry, not enough reputation to post images directly)
似乎 eclipse 的“在服务器上运行”在 tomcat-server 上部署了未过滤的应用程序。 我做错了什么?
更新: 我关注了这个链接Run Maven webapp on server from Eclipse with properties injection from profile,但我仍然收到同样的异常。
这里是我项目配置的调整:Active Maven Profiles
更新: Eclipse (Luna) 将 Web 应用程序部署到工作空间/.metadata/.plugins/.org.eclipse.wst.server.core/tmp0/wtpwebapps/applicationName。部署在那里的 settings.xml 仍然包含未过滤的变量,而生成的 .WAR-Archive(位于工作空间/应用程序名称/目标)具有正确过滤的 settings.xml。这怎么可能?
感谢您的帮助!
【问题讨论】:
-
抱歉,我没有找到这个主题。谢谢,解决了我的问题!
-
不幸的是我错了。它仍然无法正常工作。
标签: eclipse spring maven tomcat