开发者社区> 问答> 正文

设置了compilerArgument无效 :报错

maven配置:

<!-- 编译插件 -->
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.5.1</version>
    <configuration>
        <!-- 源码风格使用1.7风格 -->
        <source>1.8</source>
        <target>1.8</target>
        <encoding>UTF-8</encoding>
        <!--必须添加compilerArgument配置,才能使用JFinal的Controller方法带参数的功能-->
        <compilerArgument>-parameters</compilerArgument>
        <!--<compilerArgs>-->
            <!--<compilerArg>-parameters</compilerArg>-->
        <!--</compilerArgs>-->
        <!-- 编译跳过代码编译类 -->
        <excludes>
            <!-- 排除应用程序编译类 -->
            <exclude>**/ApplicationCodeGenerator.java</exclude>
        </excludes>
    </configuration>
</plugin>

maven编译日志

[DEBUG] Goal:          org.apache.maven.plugins:maven-compiler-plugin:3.5.1:testCompile (default-testCompile)
[DEBUG] Style:         Regular
[DEBUG] Configuration: <?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <basedir default-value="${basedir}"/>
  <buildDirectory default-value="${project.build.directory}"/>
  <classpathElements default-value="${project.testClasspathElements}"/>
  <compileSourceRoots default-value="${project.testCompileSourceRoots}"/>
  <compilerArgument>-parameters</compilerArgument>
[DEBUG]   (f) compileSourceRoots = [/data/lib/jenkins/workspace/component-system/jzdoctor-component/jzdoctor-component-system/src/main/java]
[DEBUG]   (f) compilerArgument = -parameters
[DEBUG]   (f) compilerId = javac
[DEBUG]   (f) debug = true
[DEBUG]   (f) encoding = UTF-8
[DEBUG]   (f) excludes = [**/ApplicationCodeGenerator.java]

运行警告信息:

Oct 31, 2018 10:03:13 PM com.jfinal.core.paragetter.ParaProcessorBuilder warn
WARNING: you should add compiler flag -parameters to support parameter auto binding

 

展开
收起
kun坤 2020-06-14 08:04:52 1646 0
1 条回答
写回答
取消 提交回答
  • 经过仔细排查,偶然灵机一闪,发现是因为依赖造成的!!!

    主工程依赖了一个api组件以及kit组件,主工程虽然指定了compilerArgument参数,但是api组件以及kit组件在打包的时候并未指定compilerArgument参数。

    2020-06-14 08:04:57
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载