SSM整合配置文件遇到的一些卡了很久的问题

配置文件写的时候不细心,找错误的时候流下两行泪…,写配置文件一定要细心细心细心细心细心细心,下面是部分卡了我很久的问题。。

1. java.io.FileNotFoundException: class path resource [applicationContext.xml] cannot be opened because it does not exist

这个错误是找不到配置文件了,首先考虑是不是prm.xml中没有加静态资源过滤

    <build>
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                </includes>
                <filtering>false</filtering>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                </includes>
                <filtering>false</filtering>
            </resource>
        </resources>
    </build>

然后看maven的target中能不能找到配置文件,如果加上还是报错,看一看资源路径是否正确。

==========================================
2. Error creating bean with name ‘sqlSessionFactory’ defined in class path resource [spring-mybatis.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type ‘java.lang.String’ to required type ‘javax.sql.DataSource’ for property ‘dataSource’; nested exception is java.lang.IllegalStateException: Cannot convert value of type ‘java.lang.String’ to required type ‘javax.sql.DataSource’ for property ‘dataSource’: no matching editors or conversion strategy found
'

这个错误让我找了很多天,首先可以肯定是spring整合mybatis的配置文件有问题。

  1. 首先看创建bean的SqlSessionFactory属性值DataSource赋值是不是ref,不要写成value
  2. 在mybatis-config.xml和spring-mybatis.xml中不要重复扫描xxxxMapper.xml,重复扫描会出错
  3. 网上其他方案:配置文件开头加上:default-autowire=“byname”

==========================================
3.配置文件头UTF-8莫名其妙出错

xml配置文件头:这个问题不知道出在哪,偶尔一次运行是正确的,偶尔运行爆红,只要把UTF-8改为UTF8就能正确运行。

==========================================
4.类 ‘xxxServlceImpl’ 为 public,应在文件 ‘xxxServlceImpl.java’ 中声
这是实现类名出错,会导致spring-service.xml配置文件中创建Impl类bean失败。将实现类名改为:BookServiceImpl

==========================================

5.已连接到服务器
[2021-01-23 10:20:06,566] Artifact SSMBuild:war exploded: 正在部署工件,请稍候…
23-Jan-2021 22:20:06.879 涓ラ噸 [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal 涓�涓垨澶氫釜绛涢�夊櫒鍚姩澶辫触銆傚畬鏁寸殑璇︾粏淇℃伅灏嗗湪鐩稿簲鐨勫鍣ㄦ棩蹇楁枃浠朵腑鎵惧埌
23-Jan-2021 22:20:06.880 涓ラ噸 [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal 鐢变簬涔嬪墠鐨勯敊璇紝Context[/SSMBuild_war_exploded]鍚姩澶辫触
[2021-01-23 10:20:06,891] Artifact SSMBuild:war exploded: 部署工件时出错。请参阅服务器日志了解详细信息。
23-Jan-2021 22:20:16.347 淇℃伅 [Catalina-utility-1] org.apache.catalina.startup.HostConfig.deployDirectory 鎶妛eb 搴旂敤绋嬪簭閮ㄧ讲鍒扮洰褰� [D:\Tomcat\apache-tomcat-9.0.41\webapps\manager]
23-Jan-2021 22:20:16.390 淇℃伅 [Catalina-utility-1] org.apache.catalina.startup.HostConfig.deployDirectory Web搴旂敤绋嬪簭鐩綍[D:\Tomcat\apache-tomcat-9.0.41\webapps\manager]鐨勯儴缃插凡鍦╗42]姣鍐呭畬鎴�

这个错误是IDEA项目结构中没有添加库文件,很坑,需要自己手动添加,在IDEA中打开项目结构
在这里插入图片描述
在WEB-INF中创建一个lib文件夹,然后
在这里插入图片描述
把这些库加入lib文件夹应用就可以正常运行了。

暂时就这么多,遇到问题再更新

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

yui方木

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值