构建maven聚合工程

1.对service子模块进行代码测试的时候,报错显示build false
报错:The POM for com.xq.dao:xq-maven-user-dao:jar:1.0-SNAPSHOT is missing, no dependency information available
原因:父工程的依赖没有导入
解决:在父工程先后执行clean、instal
2.在运行maven项目时,报错找不到依赖,可是依赖已在pom文件中配置完成
image
报错:Error:(3, 17) java: 程序包org.junit不存在
解决:点击file中的setting设置,勾选图中方框;
关闭项目,在启动页面右下角点击configue进行全局配置
image
3.c3p0-config.xml配置文件的内容

<?xml version="1.0" encoding="UTF-8" ?>

<c3p0-config>
    <default-config>
        <property name="driverClass">com.mysql.cj.jdbc.Driver</property>
        <property name="jdbcUrl">jdbc:mysql://localhost:3306/要连接的数据库名称</property>
        <property name="user">自己的数据库账号</property>
        <property name="password">自己的数据库密码</property>
<!--        初始化的连接对象,在连接池里面初始化10个连接对象-->
        <property name="initialPoolSize">10</property>
<!--        最大空闲时间
            某一个连接对象空闲时长最多是30s,超过了30s,该链接对象会被自动收回-->
        <property name="maxIdleTime">30</property>

<!--        最大连接数量
            在连接池里面存在最多的连接数量-->
        <property name="maxPoolSize">100</property>
<!--        最小连接数量-->
        <property name="minPoolSize">5</property>
    </default-config>
</c3p0-config>

4.对utils子模块的数据库连接进行测试,出现错误
报错:Connections could not be acquired from the underlying database!(mysql)
原因:mysql驱动版本太老了,不兼容
解决:更换比较新的版本

 <!--mysql驱动-->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.28</version>
        </dependency>

5.编辑Path环境变量双击path不展开
原因:%开头的变量移到了C开头的变量前面
解决:更换顺序,图示这些放在了下方
image
6.运行maven项目时总是报错,最后发现是idea与maven的版本不兼容
原因:idea2020.1适配apache-maven-3.6.3,高了或低了都不行
解决:去官网下载历史版本
https://archive.apache.org/dist/maven/maven-3/
点击对应版本链接
image
点击binaries
image
选择所需版本进行下载,windows就选择红框中的
image
之后解压
找到解压后的conf目录下的setting.xml文件,进行编辑
image
在这个文职添加依赖打到的本地仓库(标签中间填写一个空文件夹路径)
image
在此处添加如下代码
image

<mirror>
  <!-- mirror -->
  <id>nexus-aliyun</id>
  <!-- -->
  <mirrorOf>central</mirrorOf>
  <!-- -->
  <name>Nexus aliyun</name>
  <!-- URL -->
  <url>https://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>

在最后添加你的jdk版本(我的是jdk1.8)
image
打开idea的setting,找到maven,进行配置,从上至下依次为下载的maven文件夹路径、setting.xml文件路径、本地仓库的路径,依次点击Apply和OK,完成配置
image

posted @ 2025-09-06 18:22  f-52Hertz  阅读(7)  评论(0)    收藏  举报