2012-09-16 34 views
2

我添加了安全約束來保護應用程序的某些文件夾。本地主機的Tomcat領域安全約束禁用

<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用戶添加了合適的用戶超級用戶,當我部署應用程序時,這似乎都工作正常。然而,當我通過maven在本地從exclipse運行它時,使用tomcat7:run,我的本地設置沒有tomcat-users.xml文件,所以基本上我不知道如何在本地配置用戶。安全工作,但沒有用戶定義。

u能請告訴我如何通過或自定義指定的tomcat-sers.xml文件的內行tomcat的plugn

回答

2

我得到了它,如果有人曾經需要它。

在pom.xml中爲tomcat7-maven-plugin找到你的插件塊,並在配置中定義自定義的tomcat-users.xml路徑。

<configuration> 
    <tomcatUsers>path/tomcat-users.xml</tomcatUsers> 
</configuration>