文章目录
Spring Boot 多模块注入访问不到jar包中的Bean问题
情景描述
如图所示:
一个聚合项目
spring-security-tutorial
,其中包括4个module
,pom如下所示:<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.github.jdkong.security</groupId> <artifactId>spring-security-tutorial</artifactId> <version>1.0-SNAPSHOT</version> <packaging>pom</packaging> <modules>`` <module>security-core</module> <module>security-app</module> <module>security-browser</module> <module>security-demo</module> </modules> <!-- 其他部分省略--> </project>
在此项目中,子项目
security-browser
是一个简单的maven项目,打成jar
包,供security-demo
使用,security-demo
项目是一个springboot
项目。
问题描述
在
security-browser
项目中自动注入了一个配置类,如下所示:/** * @author jdkong */ @Slf4j @Configuration public class BrowserSecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { http.formLogin