首页 新闻 会员 周边

Mybatis 中打包方式为pom时无法找到mybatis-config.xml的问题

0
悬赏园豆:30 [已关闭问题] 关闭于 2022-10-08 21:03

今天在做mybatis入门的时候,一直卡在Could not find resource mybatis-config.xml这个问题上。找了半天发现解决办法是将pom.xml中的Packaging 方式改为jar。而用默认的pom就会爆这个错误。这是为啥????
数据库版本 8.0.13
pom.xml配置如下
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.example</groupId>
<artifactId>mavenfor</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>


<properties>
    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>
</properties>

<dependencies>
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->

<dependency>
    <groupId>org.mybatis</groupId>
    <artifactId>mybatis</artifactId>
    <version>3.5.5</version>
</dependency>
<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>8.0.13</version>
</dependency>
<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.13</version>
    <scope>test</scope>
</dependency>
<!-- 添加slf4j日志api -->
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
    <version>1.7.20</version>
</dependency>
<!-- 添加logback-classic依赖 -->
<dependency>
    <groupId>ch.qos.logback</groupId>
    <artifactId>logback-classic</artifactId>
    <version>1.2.3</version>
</dependency>
<!-- 添加logback-core依赖 -->
<dependency>
    <groupId>ch.qos.logback</groupId>
    <artifactId>logback-core</artifactId>
    <version>1.2.3</version>
</dependency>

</dependencies>

</project>

Nvan的主页 Nvan | 菜鸟二级 | 园豆:202
提问于:2022-09-07 16:00
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册