Before opening this question, I referred to the answers on StackOverflow and the official answer from Kotlin, but this is not what I wanted. I am using the Spring Boot Maven plugin, which is not the official plugin packaging for Maven. Has anyone encountered this issue?

The meaning of 'cannot find symbol'

This my maven pom.xml file

<?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>com.wansensoft</groupId>
    <artifactId>wansen-erp-core</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>
    <name>wansenerp</name>
    <description>万森ERP</description>
    <modules>
        <module>utils</module>
        <module>domain</module>
        <module>plugins</module>
        <module>middleware</module>
        <module>service</module>
        <module>dao</module>
        <module>api</module>
    </modules>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.1.4</version>
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <maven.compiler.source>21</maven.compiler.source>
        <maven.compiler.target>21</maven.compiler.target>
        <kotlin.version>1.9.10</kotlin.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>1.7.32</version>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.30</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-stdlib</artifactId>
            <version>${kotlin.version}</version>
        </dependency>
    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.jetbrains.kotlin</groupId>
                <artifactId>kotlin-maven-plugin</artifactId>
                <version>${kotlin.version}</version>
                <executions>
                    <execution>
                        <id>compile</id>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                        <configuration>
                            <sourceDirs>
                                <sourceDir>${project.basedir}/src/main/kotlin</sourceDir>
                                <sourceDir>${project.basedir}/src/main/java</sourceDir>
                            </sourceDirs>
                        </configuration>
                    </execution>
                    <execution>
                        <id>test-compile</id>
                        <goals>
                            <goal>test-compile</goal>
                        </goals>
                        <configuration>
                            <sourceDirs>
                                <sourceDir>${project.basedir}/src/test/kotlin</sourceDir>
                                <sourceDir>${project.basedir}/src/test/java</sourceDir>
                            </sourceDirs>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <finalName>wansenerp</finalName>
                    <mainClass>com.wansensoft.api.ErpApplication</mainClass>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

He reported an error saying:

[INFO] 3 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for wansenerp 1.0-SNAPSHOT:
[INFO] 
[INFO] wansenerp .......................................... SUCCESS [  0.721 s]
[INFO] utils .............................................. SUCCESS [  5.760 s]
[INFO] domain ............................................. SUCCESS [  2.975 s]
[INFO] plugins ............................................ SUCCESS [  0.055 s]
[INFO] dao ................................................ SUCCESS [  0.679 s]
[INFO] middleware ......................................... SUCCESS [  0.735 s]
[INFO] service ............................................ FAILURE [  0.735 s]
[INFO] api ................................................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  11.908 s
[INFO] Finished at: 2023-10-05T19:28:57+08:00
[INFO] ------------------------------------------------------------------------
[WARNING] 
[WARNING] Plugin validation issues were detected in 1 plugin(s)
[WARNING] 
[WARNING]  * org.springframework.boot:spring-boot-maven-plugin:3.1.4
[WARNING] 
[WARNING] For more or less details, use 'maven.plugin.validation' property with one of the values (case insensitive): [BRIEF, DEFAULT, VERBOSE]
[WARNING] 
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:compile (default-compile) on project service: Compilation failure: Compilation failure: 
[ERROR] /E:/opensource/WansenERP/service/src/main/java/com/wansensoft/service/user/impl/SysUserServiceImpl.java:[30,35] 程序包com.wansensoft.service.role不存在
[ERROR] /E:/opensource/WansenERP/service/src/main/java/com/wansensoft/service/user/impl/SysUserServiceImpl.java:[84,19] 找不到符号
[ERROR]   符号:   类 SysRoleMenuRelService
[ERROR]   位置: 类 com.wansensoft.service.user.impl.SysUserServiceImpl
[ERROR] /E:/opensource/WansenERP/service/src/main/java/com/wansensoft/service/user/impl/SysUserServiceImpl.java:[87,164] 找不到符号
[ERROR]   符号:   类 SysRoleMenuRelService
[ERROR]   位置: 类 com.wansensoft.service.user.impl.SysUserServiceImpl
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <args> -rf :service

找不到符号 的意思为:The meaning of 'cannot find symbol'

Comment From: Jzow

If I directly use Maven to package without using the Spring boot Maven plugin, there is no error in packaging it

Comment From: wilkinsona

When you package a shared module as a Spring Boot application, its classes move into BOOT-INF/classes which hides them from the classpath of any modules that depend upon it. For this reason, you shouldn't apply Spring Boot's Maven plugin to every module, just those that contain a complete application.

If, for some reason, you have to depend on a module that contains a complete application, the reference documentation describes how to do so.

If you have any further questions, please follow up on Stack Overflow. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements. If you do ask a question on Stack Overflow, please provide a complete, yet minimal example of the problem. A single pom.xml file from a multi-module build isn't sufficient to offer specific guidance.

Comment From: Jzow

ThanksSent from my iPhoneOn Oct 5, 2023, at 21:41, Andy Wilkinson @.***> wrote: When you package a shared module as a Spring Boot application, its classes move into BOOT-INF/classes which hides them from the classpath of any modules that depend upon it. For this reason, you shouldn't apply Spring Boot's Maven plugin to every module, just those that contain a complete application. If, for some reason, you have to depend on a module that contains a complete application, the reference documentation describes how to do so. If you have any further questions, please follow up on Stack Overflow. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements. If you do ask a question on Stack Overflow, please provide a complete, yet minimal example of the problem. A single pom.xml file from a multi-module build isn't sufficient to offer specific guidance.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>