• 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"/>
  • 相关阅读:
    javascript库之Mustache库使用说明
    Android开发之底部导航栏标准
    Android开发之欢迎界面标准
    c和c++如何把一个整数转化为string
    stringstream用法
    实战c++中的string系列--std:vector 和std:string相互转换(vector to stringstream)
    C++11使用make_shared的优势和劣势
    C++11 并发指南五(std::condition_variable 详解)
    C++17 std::shared_mutex的替代方案boost::shared_mutex
    std::shared_mutex和std::mutex的性能对比(banchmark)
  • 原文地址:https://www.cnblogs.com/changlili/p/10113113.html
Copyright © 2020-2023  润新知