我已经将MVC MitreID Spring Web应用程序剪切并粘贴到基本的引导Web应用程序中.当我尝试运行它时,我得到:
A component required a bean named 'namedAdmins' that could not be found
代码是:
import org.mitre.openid.connect.client.OIDCAuthenticationFilter;
import org.mitre.openid.connect.client.SubjectIssuerGrantedAuthority;
@RestController
public class HomeController {
private static final Logger logger = LoggerFactory.getLogger(HomeController.class);
@Autowired
private OIDCAuthenticationFilter filter;
@Resource(name = "namedAdmins")
private Set<SubjectIssuerGrantedAuthority> admins;
@RequestMapping(value = "/",method = RequestMethod.GET)
这只是我将@controller更改为@restcontroller的Spring代码.
这是在servlet-context.xml中:
<bean id="openIdConnectAuthenticationProvider" class="org.mitre.openid.connect.client.OIDCAuthenticationProvider">
<property name="authoritiesMapper">
<bean class="org.mitre.openid.connect.client.NamedAdminAuthoritiesMapper">
<property name="admins" ref="namedAdmins" />
</bean>
</property>
</bean>
<util:set id="namedAdmins" value-type="org.mitre.openid.connect.client.SubjectIssuerGrantedAuthority">
<bean class="org.mitre.openid.connect.client.SubjectIssuerGrantedAuthority">
<constructor-arg name="subject" value="90342.ASDFJWFA" />
<constructor-arg name="issuer" value="http://192.168.1.114:8080/openid-connect-server-webapp/" />
</bean>
</util:set>
任何人都可以请我着手进行我需要更改的其他内容/在哪里寻找才能识别Bean的信息吗?
这是在我的pom中:
<dependency>
<groupId>org.mitre</groupId>
<artifactId>openid-connect-client</artifactId>
<version>1.3.1</version>
</dependency>
最佳答案
您的servlet-context.xml很可能未包含在Spring Boot应用程序中.使用@ImportResource批注导入
@SpringBootApplication
@ImportResource("servlet-context.xml")
public class MyApp {
// ...
}
或将此XML转换为新的Java配置类,这将是首选方法:
@Configuration
public class MitreConfig {
@Bean
public Set<SubjectIssuerGrantedAuthority> namedAdmins() {
// ...
}
}