2017-03-08 64 views
0

我试图让一个CAS服务器启动并使用https://github.com/apereo/cas-overlay-template作为一个侧面项目(我是一名学生),但我从未使用过maven或spring。deployerConfigContext.xml没有任何作用

我试图把我自己的IPersonAttributeDao挂接到CAS服务器。但是,当我将我的deployerConfigContext.xml放在src/main/webapp/WEB-INF/下时,我重新打包(使用构建脚本)并将其部署到tomcat8时没有任何变化。 (是的,我确实重新启动了tomcat)。

下面我deployerConfigContent.xml文件的内容

<?xml version="1.0" encoding="UTF-8"?> 

<beans xmlns="http://www.springframework.org/schema/beans" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xmlns:p="http://www.springframework.org/schema/p" 
     xmlns:tx="http://www.springframework.org/schema/tx" 
     xmlns:sec="http://www.springframework.org/schema/security" 
     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd 
     http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd 
     http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd"> 

    <bean id="authenticationManager" class="org.jasig.cas.authentication.AuthenticationManagerImpl"> 
     <property name="credentialsToPrincipalResolvers"> 
      <list> 
       <bean id="primaryPrincipalResolver" 
         class="org.jasig.cas.authentication.principal.PersonDirectoryPrincipalResolver"> 
        <property name="attributeRepository" ref="attributeRepository"/> 
       </bean> 
       <bean class="org.jasig.cas.authentication.principal.UsernamePasswordCredentialsToPrincipalResolver"> 
        <property name="attributeRepository" ref="attributeRepository"/> 
       </bean> 

       <bean class="org.jasig.cas.authentication.principal.HttpBasedServiceCredentialsToPrincipalResolver"> 
        <property name="attributeRepository" ref="attributeRepository"/> 
       </bean> 
      </list> 
     </property> 
     <property name="authenticationHandlers"> 
      <list> 
       <bean id="primaryAuthenticationHandler" 
         class="org.jasig.cas.authentication.AcceptUsersAuthenticationHandler"> 
        <property name="users"> 
         <map> 
          <!-- Login stays the default casuser:Mellon, no idea why --> 
          <entry key="test" value="1234"/> 
         </map> 
        </property> 
       </bean> 
       <!-- DO NOT EVER PUT THIS BEAN IN PRODUCTION!!! --> 
       <bean class="org.jasig.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler"/> 
      </list> 
     </property> 
    </bean> 

    <!-- <bean id="attributeRepository" class="class.i.am.trying.to.hook.in"> 
    </bean>--> 

    <!-- This doesn't seem to work --> 
    <bean id="attributeRepository" 
      class="org.jasig.services.persondir.support.StubPersonAttributeDao"> 
     <property name="backingMap"> 
      <map> 
       <entry key="uid" value="uid" /> 
       <entry key="eduPersonAffiliation" value="eduPersonAffiliation" /> 
       <entry key="groupMembership" value="groupMembership" /> 
      </map> 
     </property> 
    </bean> 
</beans> 

我缺少什么?

UPDATE:

我重读文档(https://apereo.github.io/cas/5.0.x/),发现deployerConfigContext.xml里应该是在resources,而不是webapp/WEB-INF,因为我在互联网上找到。我移动它,现在我终于在日志中出现错误(这意味着文件正在被读取)。下面

错误:

org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.jasig.cas.authentication.PolicyBasedAuthenticationManager] for bean with name 'authenticationManager' defined in class path resource [deployerConfigContext.xml] 

我发现,在文档到PolicyBasedAuthenticationManager参考,但在尝试那(ofcourse与其他类名)给了同样的错误。

+0

您的CAS服务器中可能存在版本问题。检查依赖关系以确定具体的类。 –

回答

0

已启用Bean的Bean类必须部署在Bean归档中。

库罐子,罐子EJB,应用程序客户端JAR或RAR压缩包是 豆存档,如果它有一个名为beans.xml中的META-INF目录 文件。如果 在战争的WEB-INF目录中有一个名为beans.xml的文件,则战争的WEB-INF/classes目录是一个bean存档。如果在META-INF目录中有一个名为beans.xml的文件 ,则JVM类路径中的 目录是一个Bean归档文件。

一个建议,如果您使用的是Spring,您还可以设置@Annotation来定义bean。

+0

原来'deployerConfigContext.xml'应该放在另一个目录中,而不是我在互联网上找到的目录(可能它已经改变了最新的CAS版本?)。现在我的日志中出现错误(请参阅更新后的问题)。 – Soronbe

+0

@Soronbe可以声明缺少的bean并查看它是否可以解决此问题。 – Simon

+0

@Soronbe如果你正在实现一个CAS系统,并计划使用Spring,Spring Security,可能会检出这个https://simonlzn.github.io/2016/11/20/CAS-with-Spring-Security.html。 – Simon