此消息显示:Required authorization. To access on the server http://localhhost:8080 you should enter login and password. Server message: Spring
。
我正在使用Hibernate 4,Spring 4和Gradle。另外,我正在使用Spring Boot。但即使我从tutorial获得了平面代码,也会显示此消息。是什么引起了它以及如何摆脱它?怎么了?控制台中没有错误消息。
答案 0 :(得分:13)
在项目中搜索security properties
并设置
security.basic.enabled=false
检查上述链接中的 66.1 。
来自Doc:如果您在应用程序的任何位置使用@EnableWebSecurity定义@Configuration,它将关闭Spring Boot中的默认Webapp安全设置
答案 1 :(得分:2)
我重新启动它只需在security.basic.enabled=false
文件application.properties
中添加src/main/resouces
即可。Customer
希望这可以帮助你:) ps.this文件由IDEA生成,如果你没有,只需自己创建。
答案 2 :(得分:0)
看起来像一些basic-auth。
Basic-auth通常在web.xml
或spring security中配置。如果您的代码没有spring security,请检查web.xml
,例如:
<security-constraint>
<web-resource-collection>
<url-pattern>/</url-pattern>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<description>only registered user</description>
<role-name>ROLE_USER</role-name>
</auth-constraint>
</security-constraint>
并将其删除。 (但是,那些需要认证的东西可能无法正常工作!)
答案 3 :(得分:0)
从同一个教程运行应用程序时遇到了同样的问题。
我使用IntelliJ IDEA 14.1.4并在项目依赖项中选择了Core_Security like that虽然只需要Web_Web依赖项。
然后我真的不知道如何删除它,所以我创建了没有它的新项目,问题已经消失。