Java 中常见报错

Siona

Java 中常见报错

Maven

1. package 或 install 找不到包问题

package com.qx.common.exception does not exist
maven 找不到包问题.png
maven 找不到包问题.png

解决方法:

<!-- 父模块 pom.xml 中去掉 build -->
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <excludes>
                    <exclude>
                        <groupId>org.projectlombok</groupId>
                        <artifactId>lombok</artifactId>
                    </exclude>
                </excludes>
            </configuration>
        </plugin>
    </plugins>
</build>

原因:父模块不需要打包❓

2. 打包好的 jar 启动报错 no main manifest attribute

# xxx.jar 中没有主清单属性
no main manifest attribute, in xxx.jar

解决方法:

<!-- api module 中 pom.xml Build 用下面的 -->
<build>
    <finalName>${project.artifactId}</finalName>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

原因:api 模块与 common、dao 模块的 Build 不一样 ❓

Last Updated 3/2/2024, 4:00:59 PM