nutzam / nutzboot-maven-plugin

2 stars 4 forks source link

项目中使用了java14的preview特性时,无法使用「直接运行」命令 #12

Closed ywjno closed 4 years ago

ywjno commented 4 years ago

pom.xml 中 plugin 的配置如下

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>14</source>
                    <target>14</target>
                    <compilerArgs>
                        --enable-preview
                    </compilerArgs>
                    <useIncrementalCompilation>false</useIncrementalCompilation>
                </configuration>
            </plugin>

然后运行 mvn compile nutzboot:run 命令时控制台提示

[ERROR] Failed to execute goal org.nutz.boot:nutzboot-maven-plugin:2.4.1-SNAPSHOT:run (default-cli) on project test: An exception occured while executing the Java class. Preview f
eatures are not enabled for com/test/MainLauncher (class file version 58.65535). Try running with '--enable-preview' -> [Help 1]

貌似没用到 --enable-preview 这个参数。

ywjno commented 4 years ago

该问题跟插件无关,需要在运行该命令前先运行 export MAVEN_OPTS=--enable-preview, 设置maven参数后即可