我添加了安全约束来保护应用程序的某些文件夹。
<security-constraint>
<web-resource-collection>
<web-resource-name>panel</web-resource-name>
<url-pattern>/secured/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>super</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>Panel</realm-name>
</login-config>
我向 tomcat-users 添加了正确的用户 SUPER,当我部署应用程序时,这一切似乎都工作正常。但是,当我通过 maven 从 exclipse 本地运行它时,使用 tomcat7:run ,我的本地设置没有 tomcat-users.xml 文件,所以基本上我不知道如何在本地配置用户。安全性有效,但未定义用户。
您能告诉我如何为 mavens tomcat 插件传递或指定自定义 tomcat-sers.xml 文件吗
最佳答案
如果有人需要的话,我得到了。
在 pom.xml 中找到 tomcat7-maven-plugin 的插件 block ,并在配置中指定自定义 tomcat-users.xml 路径。
<configuration>
<tomcatUsers>path/tomcat-users.xml</tomcatUsers>
</configuration>
关于maven - Tomcat Realm 安全约束对本地主机禁用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12448246/