五、开发问题记录
问题1: Maven拥有同一级parent无法成功导入同项目别的依赖。(报错信息:Failed to read artifact descriptor for com.funnee…)
解决: 通过C:\用户.m2\repository发现父项依赖并没有成功安装在本地仓库,重新安装父项依赖(在父项pom的同级目录执行命令mvn -U install(将包安装在本地仓库),然后再去子项目刷新maven即可)
问题2: 被引入项目的websecurity配置类(adapter)不生效
解决: ①在springboot启动类添加注解
@ComponentScan(basePackages = {“com.funnee.browser”}),能够扫描到该类。
②被引入项目的Maven配置需要添加下面代码
<build>
<!--将本地代码封入包内-->
<sourceDirectory>src/main/java</sourceDirectory>
</build>
问题3: 配置自定义页面时,遇到循环重定向的问题。
解决: 因为配置了自定义登录页loginPage,然而又对所有请求进行授权要求,因此loginPage就又发向loginPage请求授权,如此循环下去。将匹配loginPage的URL放行就不会出现这种现象。
@Configuration
@EnableWebSecurity
public class BrowserSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.formLogin()
.loginPage("/login/login.html")
.and()
.authorizeRequests()
.antMatchers("/login/login.html").permitAll()//添加这句得以解决
.anyRequest()
.authenticated();
}
}
问题4: browserProperty get set 对象名不一致导致
1spring MVC方式
2.spring boot方式
3.整合CAS