2021年7月28日 | Leave a comment 问题: maven 项目中如何启用 JDK preview 功能 解决: 在 pom.xml 配置 <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.0</version> <configuration> <release>13</release> <compilerArgs> --enable-preview </compilerArgs> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>3.0.0-M3</version> <configuration> <argLine>--enable-preview</argLine> </configuration> </plugin> </plugins> </build> 1234567891011121314151617181920212223 <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.0</version> <configuration> <release>13</release> <compilerArgs> --enable-preview </compilerArgs> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>3.0.0-M3</version> <configuration> <argLine>--enable-preview</argLine> </configuration> </plugin> </plugins> </build> 参考: https://stackoverflow.com/questions/52232681/compile-and-execute-a-jdk-preview-feature-with-maven