Spring 自动注解 相同类名过滤

    第一次在这里面写文章,其实是寻求大家帮助,现在我一个javaWeb项目用到的是spring自动注解(
<context:component-scan base-package="com.magus"  >
),这个项目里面用到了公司自己编写的一个jar包,jar包里面有两个类 com.magus.net.security.User和com.magus.net.User,这样的话启动的时候就会报如下错:
Annotation-specified bean name 'user' for bean class [com.magus.net.security.User] conflicts with existing, non-compatible bean definition of same name and class [com.magus.net.User]


  我知道spring自动注解不能有相同的类名,即使不在同一个包下面也不行,其实我注解的时候不需要注解我用到的这个jar包,我不知道怎么配置让它不去注解特定的类。我试过网上说的,

<context:component-scan base-package="com.magus"  >
   <context:exclude-filter type="regex" expression="com/.magus/.net.*" />
     <context:exclude-filter type="regex" expression="com/.magus/.io.*" />
   <context:exclude-filter type="regex" expression="com/.magus/.security.*" />

</context:component-scan>

但是这样也没有作用,希望各位编程网友帮忙解答一下,谢谢!

你可能感兴趣的:(spring,自动注解,相同的类名)