问题记录

问题记录:

1. Spring java配置及注解注入方法出现空指针异常的原因

当通过new的方式创建一个对象的时候,虽然期望使用了注解@Autowired对这个对象进行装配,但是Spring是不会这么做的,因为Spring不会对任意一个new 出来的对象进行自动装配,只有这个对象也是一个在Spring中注册过的Bean,才会获得自动装配的功能。

2、Tomcat启动后,日志出现中文乱码的规避操作

修改tomcat/conf/logging.properties中如下配置:
java.util.logging.ConsoleHandler.encoding = utf-8
更改为
java.util.logging.ConsoleHandler.encoding = GBK

3、Tomcat启动,提示找不到XXX.xml

运用IDEA本地选择Tomcat Server 来debug工程,报错

org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [applicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [applicationContext.xml] cannot be opened because it does not exist

进入到Project Structure中,查看工程的war:exploded中的Output directory,确认war包被输出到webapps中,
然后去到该路径下,查看WEB-INF\classes中是否包含了缺少的applicationContext.xml,
如果确认缺少,则说明打war包的时候,没有将这个文件打到war包中,需要关注工程中pom.xml中build中,是否对resource进行了排出;
比如:

<resources>
            <resource>
                <directory>resources</directory>
               <excludes>
                    <exclude>*</exclude>
                </excludes>
            </resource>
</resources>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值