这里为了省略security的标签头所以修改了Bean标签的写法;
<?xml version="1.0" encoding="UTF-8"?> <beans:beans xmlns="http://www.springframework.org/schema/security" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd"> <!-- 释放静态资源 --> <http pattern="/login.html" security="none"></http> <http pattern="/*.html" security="none"></http> <http pattern="/css/**" security="none"></http> <http pattern="/img/**" security="none"></http> <http pattern="/js/**" security="none"></http> <http pattern="/plugins/**" security="none"></http> <!-- auto-config="true" 表示springsecurity框架会自动寻找认证页面 如果我们自己没有提供,则使用springsecurity默认的认证页面 如果我们自己有认证页面,需要配置才能使用 use-expressions="true" 如果是true表示使用spring的el表达式进行配置 如果是false则可以直接配置 --> <http auto-config="true" use-expressions="false"> <!--对当前项目的所有资源进行拦截--> <intercept-url pattern="/**" access="ROLE_ADMIN" /> <!-- <security:intercept-url pattern="/**" 表示要拦截项目中的所有资源 access="hasAnyRole('ROLE_USER','ROLE_ADMIN')" 当用户有ROLE_USER角色或者ROLE_ADMIN角色的时候才能访问资源 其中springsecurity规定角色的名称必须以ROLE_开头。 --> <!--配置自己的认证页面--> <form-login login-page="/login.html" default-target-url="/admin/index.html" authentication-failure-url="/login.html" always-use-default-target="true" /> <!--关闭csrf拦截--> <csrf disabled="true" /> <!--配置退出认证信息--> <logout/> <!--如果你在系统中使用了框架页,需要设置框架页的策略为 SAMEORIGIN --> <headers> <frame-options policy="SAMEORIGIN" /> </headers> </http> <!-- 认证管理器 --> <authentication-manager> <authentication-provider> <user-service> <user name="admin" password="123456" authorities="ROLE_ADMIN" /> <user name="sunwukong" password="dasheng" authorities="ROLE_ADMIN" /> </user-service> </authentication-provider> </authentication-manager> </beans:beans>: Error creating bean with name ‘sellerService’: FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: com.pingyougou.sellergoods.service.sellerService at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:175) at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:103) at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1585) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:317) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351) … 103 more
原因在 <dubbo:application name=“pinyougou-shop-web” /> <dubbo:registry address=“zookeeper://192.168.25.128:2181”/> <dubbo:reference id=“sellerService” interface=“com.pingyougou.sellergoods.service.sellerService”/> 使用 dubbo扫描配置文件的时侯interface="com.pingyougou.sellergoods.service.sellerService"类名没有大写规范;
org.springframework.beans.NotWritablePropertyException: Invalid property ‘postDao’ of bean class?
private SellerService sellerservice; public void setSellerservice(SellerService sellerservice) { this.sellerservice = sellerservice; }
<beans:bean id=“userServiceImpl” class=“com.pinyougou.service.UserServiceImpl”> <beans:property name=“sellerservice” ref=“sellerService”></beans:property> </beans:bean>
set依赖注入方式错误,在使用set注入依赖的时候,你引入的property的name必须等于你set方式的对象name
也就是sellerservice = sellerservice; √ 如果是你set方式的参数是sellerService 然后property 的name是sellerservice就会报错;
. Could not load org.apache.zookeeper.proto.SetWatches. The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact. java.lang.IllegalStateException at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1588) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547) at org.apache.zookeeper.ClientCnxn S e n d T h r e a d . p r i m e C o n n e c t i o n ( C l i e n t C n x n . j a v a : 926 ) a t o r g . a p a c h e . z o o k e e p e r . C l i e n t C n x n S o c k e t N I O . d o T r a n s p o r t ( C l i e n t C n x n S o c k e t N I O . j a v a : 363 ) a t o r g . a p a c h e . z o o k e e p e r . C l i e n t C n x n SendThread.primeConnection(ClientCnxn.java:926) at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:363) at org.apache.zookeeper.ClientCnxn SendThread.primeConnection(ClientCnxn.java:926)atorg.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:363)atorg.apache.zookeeper.ClientCnxnSendThread.run(ClientCnxn.java:1141) 原因:在分布式的项目中,必须先开service层向注册中心提交地址然后在开web层;
