• Spring搭建练习遇到的坑


    1.Error:(7, 23) java: cannot find symbol
    symbol: class ProceedingJoinPoint
    location: class com.how2java.aspect.LoggerAspect

    解决方法:

    使用idea生成Spring框架.默认的jar里面没有这两个jar包,需要去maven仓库: https://mvnrepository.com/artifact/org.aspectj 找到下载这两个包

    放入项目lib下,怎么添加参考: https://blog.csdn.net/chensanwa/article/details/79165528

     2.

    Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 30 in XML document from class path resource [spring-config.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 30; columnNumber: 17; cvc-complex-type.2.4.c: The matching wildcard is strict, 

    Caused by: org.xml.sax.SAXParseException; lineNumber: 30; columnNumber: 17; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'aop:config'.
    错误原因是:

    在spring-configuration.xml配置<aop : config> 按ALT+ENTER 会自动导入需要的xmlns,默认导入的是:

    xmlns:aop="http://www.springframework.org/schema/p"
    引发错误
    解决办法:参考 https://stackoverflow.com/questions/10062186/spring-aop-no-declaration-can-be-found-for-element-aopconfig
    xmlns:aop="http://www.springframework.org/schema/aop"
    xsi:schemaLocation="
    http://www.springframework.org/schema/aop
    http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"

    3.
    Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: 
    Error creating bean with name 'com.how2java.test.TestSping1': Unsatisfied dependency expressed through field 'c'; 
    nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException:
    Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: 
    No qualifying bean of type 'com.how2java.pojo.Category' available: expected at least 1 bean which qualifies as autowire candidate.
    Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    出错原因:
    未在spring-config.xml 中配置
    <context:component-scan base-package="com.how2java.pojo"/>
    而在测试类里面:Category在pake :com.how2java.pojo 包下面
    @RunWith(SpringJUnit4ClassRunner.class)
    @ContextConfiguration(locations = {"classpath:spring-config.xml"})
    public class TestSping1 {
    @Autowired
    Category c;

    @Test
    public void test(){
    System.out.println(c.getName());
    }
    }
    解决方法:
    在spring-config.xml 中配置
    <context:component-scan base-package="com.how2java.pojo"/>
  • 相关阅读:
    勤于思考:jquery.getJSON的缓存问题的解决方法
    步步为营:SQLServer查询随机不相同的记录插入临时表
    勤于思考:Asp.Net MVC Html.TextBoxFor日期格式化
    勤于思考:Excel写公式换算单元格求积等
    步步为营:ASP.NET MVC中Area分层模块处理大解密
    步步为营:因为数据库正在使用,所以无法获得对数据库的独占访问权
    勤于思考:从客户端中检测到有潜在危险的 Request.Form 值
    Android天天数钱游戏项目源码
    iOS猜拳游戏源码
    李开复:AlphaGo 若打败了世界冠军,意味着什么?
  • 原文地址:https://www.cnblogs.com/changlili/p/10113113.html
Copyright © 2020-2023  润新知