美文网首页随笔
maven打包报错

maven打包报错

作者: Grey____ | 来源:发表于2018-08-24 15:37 被阅读0次

问题描述:java、scala混用的情况下,maven打包,遇到找不到符号的报错。

原因:若在java代码中调用了scala代码,则需先编译scala代码,后编译java代码。


解决方案 :

解决方案1:

参考1:https://blog.csdn.net/ilvchocolate/article/details/75626921

第一步:

mvn clean scala:compile compile

第二步:

mvn package

解决方案2:

上文参考的pom.xml的build无效,故贴上我测试后可用的插件配置

<build>
    <plugins>
        <plugin>
            <groupId>org.scala-tools</groupId>
            <artifactId>maven-scala-plugin</artifactId>
            <version>2.15.2</version>
            <executions>
                <execution>
                    <id>compile-scala</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>add-source</goal>
                        <goal>compile</goal>
                    </goals>
                </execution>
                <execution>
                    <id>test-compile-scala</id>
                    <phase>test-compile</phase>
                    <goals>
                        <goal>add-source</goal>
                        <goal>testCompile</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <scalaVersion>2.11.0</scalaVersion>
                <recompileMode>incremental</recompileMode>
                <args>
                    <arg>-unchecked</arg>
                    <arg>-deprecation</arg>
                    <arg>-feature</arg>
                </args>
            </configuration>
        </plugin>
        <plugin>
            <groupId>net.alchim31.maven</groupId>
            <artifactId>scala-maven-plugin</artifactId>
            <version>3.2.2</version>
            <executions>
                <execution>
                    <id>compile-scala</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>add-source</goal>
                        <goal>compile</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
    </build>

相关文章

网友评论

    本文标题:maven打包报错

    本文链接:https://www.haomeiwen.com/subject/gpzbiftx.html