0

Spring boot项目执行时mvn compile有一些信息如下

[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ foo_app ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 13 source files to /Users/my/workspace/.../target/classes

[INFO] .../Foo.java: .../Foo.java uses unchecked or unsafe operations.

[INFO] .../Foo.java: Recompile with -Xlint:unchecked for details.

使用 spring-boot-maven-plugin

        <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>

如何设置-Xlint:uncheckedspring-boot-maven-plugin

4

1 回答 1

0

spring-boot-maven-plugin 使用 maven-compiler-plugin。要启用 Xlint,您需要使用现有的 spring-boot-maven-plugin 配置更新 maven-compiler-plugin 的配置。

<plugins>
<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
        <compilerArgs>
            <arg>-Xlint:unchecked</arg>
        </compilerArgs>
    </configuration>
</plugin>
于 2022-01-10T10:34:47.827 回答