如何在Apache Storm 0.9.3的maven中启用java 7

时间:2015-05-30 23:48:56

标签: maven plugins pom.xml apache-storm

我目前在Ubuntu 14.04 LTS中使用Apache Storm 0.9.3。我遇到Apache Storm 0.9.3中的maven编译器继续使用Java 6,尽管我已经安装了Java 7。

我的Ubuntu中的Java版本:

java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) Client VM (build 24.80-b11, mixed mode)

我的Ubuntu中的Maven版本:

Apache Maven 3.0.5
Maven home: /usr/share/maven
Java version: 1.7.0_80, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.13.0-52-generic", arch: "i386", family: "unix"

以下是我遇到的错误:

[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for org.apache.storm:storm-starter:jar:0.9.3
[WARNING] 'reporting.plugins.plugin.version' for org.apache.maven.plugins:maven-javadoc-plugin is missing. @ org.apache.storm:storm:0.9.3, /home/user/.m2/repository/org/apache/storm/storm/0.9.3/storm-0.9.3.pom, line 694, column 21
[WARNING] 'reporting.plugins.plugin.version' for org.apache.maven.plugins:maven-surefire-report-plugin is missing. @ org.apache.storm:storm:0.9.3, /home/user/.m2/repository/org/apache/storm/storm/0.9.3/storm-0.9.3.pom, line 660, column 21
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building storm-starter 0.9.3
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-remote-resources-plugin:1.2.1:process (default) @ storm-starter ---
[INFO] 
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ storm-starter ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 8 resources
[INFO] Copying 3 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ storm-starter ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 48 source files to /home/user/storm/examples/storm-starter/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /home/user/storm/examples/storm-starter/src/jvm/storm/starter/bolt/PNMSTD.java:[79,19] strings in switch are not supported in -source 1.6
  (use -source 7 or higher to enable strings in switch)
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 17.856s
[INFO] Finished at: Sun May 31 06:55:27 MYT 2015
[INFO] Final Memory: 18M/51M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project storm-starter: Compilation failure
[ERROR] /home/user/storm/examples/storm-starter/src/jvm/storm/starter/bolt/PNMSTD.java:[79,19] strings in switch are not supported in -source 1.6
[ERROR] (use -source 7 or higher to enable strings in switch)
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

以下是 /home/user/.m2/repository/org/apache/storm/storm/0.9.3/storm-0.9.3.pom 的一部分与maven有关:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

<prerequisites>
    <maven>3.0.0</maven>
</prerequisites>

<modules>
    <module>storm-buildtools/maven-shade-clojure-transformer</module>
    <module>storm-core</module>
    <module>examples/storm-starter</module>
    <module>external/storm-kafka</module>
    <module>external/storm-hdfs</module>
    <module>external/storm-hbase</module>
</modules>
<profiles>
    <profile>
        <id>sign</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-gpg-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>sign-artifacts</id>
                            <phase>verify</phase>
                            <goals>
                                <goal>sign</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
    <profile>
        <id>dist</id>
        <modules>
            <module>storm-dist/binary</module>
            <module>storm-dist/source</module>
        </modules>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-source-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>attach-sources</id>
                            <goals>
                                <goal>jar</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>attach-javadocs</id>
                            <goals>
                                <goal>jar</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <configuration>
                        <archive>
                            <manifest>
                                <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                                <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                            </manifest>
                        </archive>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>

</profiles>

<distributionManagement>
    <site>
        <id>storm.maven.website</id>
        <name>Storm Website</name>
        <url>file:///tmp/site</url>
    </site>
</distributionManagement>

<repositories>
    <repository>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
        <id>central</id>
        <url>http://repo1.maven.org/maven2/</url>
    </repository>
    <repository>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
        <id>clojars</id>
        <url>https://clojars.org/repo/</url>
    </repository>
</repositories>

    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.2.2</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-install-plugin</artifactId>
                <version>2.4</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.2.1</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>2.9</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.4</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>2.5</version>
            </plugin>
            <plugin>
                <groupId>com.theoryinpractise</groupId>
                <artifactId>clojure-maven-plugin</artifactId>
                <version>1.3.18</version>
                <extensions>true</extensions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-report-plugin</artifactId>
                <version>2.16</version>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-gpg-plugin</artifactId>
                <version>1.4</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>2.2</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-project-info-reports-plugin</artifactId>
                <version>2.7</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-site-plugin</artifactId>
                <version>3.3</version>
            </plugin>
        </plugins>
    </pluginManagement>

    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-release-plugin</artifactId>
            <configuration>
                <autoVersionSubmodules>true</autoVersionSubmodules>
                <tagNameFormat>v@{project.version}</tagNameFormat>
            </configuration>
        </plugin>
        <plugin>
            <groupId>com.theoryinpractise</groupId>
            <artifactId>clojure-maven-plugin</artifactId>
            <extensions>true</extensions>
        </plugin>
    </plugins>
</build>

<reporting>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-checkstyle-plugin</artifactId>
            <version>2.11</version>
            <reportSets>
                <reportSet>
                    <reports>
                        <report>checkstyle</report>
                    </reports>
                </reportSet>
            </reportSets>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-pmd-plugin</artifactId>
            <version>3.0.1</version>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-report-plugin</artifactId>
            <configuration>
                <reportsDirectories>
                    <file>${project.build.directory}/test-reports</file>
                    <file>${project.build.directory}/surefire-reports</file>
                </reportsDirectories>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>taglist-maven-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <tagListOptions>
                    <tagClasses>
                        <tagClass>
                            <displayName>Todo Work</displayName>
                            <tags>
                                <tag>
                                    <matchString>TODO</matchString>
                                    <matchType>exact</matchType>
                                </tag>
                                <tag>
                                    <matchString>FIXME</matchString>
                                    <matchType>exact</matchType>
                                </tag>
                            </tags>
                        </tagClass>
                    </tagClasses>
                </tagListOptions>
            </configuration>
        </plugin>
        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        </plugin>
        <plugin>
            <groupId>org.apache.rat</groupId>
            <artifactId>apache-rat-plugin</artifactId>
            <version>0.11</version>
            <configuration>
                <excludeSubProjects>false</excludeSubProjects>
                <excludes>
                    <!-- exclude maven artifacts -->
                    <exclude>**/target/**</exclude>
                    <!-- exclude intellij projects -->
                    <exclude>**/*.iml</exclude>

                    <!-- exclude CHANGELOG, VERSION, AND TODO files -->
                    <exclude>**/CHANGELOG.md</exclude>
                    <exclude>**/README.md</exclude>
                    <exclude>**/README.markdown</exclude>
                    <exclude>**/DEVELOPER.md</exclude>
                    <exclude>**/BYLAWS.md</exclude>
                    <exclude>**/STORM-UI-REST-API.md</exclude>
                    <exclude>SECURITY.md</exclude>
                    <exclude>VERSION</exclude>
                    <exclude>TODO</exclude>
                    <!-- thrift-generated code -->
                    <exclude>**/src/py/**</exclude>

                    <!-- the following are in the LICENSE file -->
                    <exclude>**/src/ui/public/js/jquery-1.6.2.min.js</exclude>
                    <exclude>**/src/ui/public/js/jquery.cookies.2.2.0.min.js</exclude>
                    <exclude>**/src/ui/public/js/jquery.tablesorter.min.js</exclude>
                    <exclude>**/src/ui/public/js/moment.min.js</exclude>
                    <exclude>**/src/ui/public/js/jquery.blockUI.min.js</exclude>
                    <exclude>**/src/ui/public/js/url.min.js</exclude>
                    <exclude>**/src/ui/public/js/arbor.js</exclude>
                    <exclude>**/src/ui/public/js/arbor-graphics.js</exclude>
                    <exclude>**/src/ui/public/js/arbor-tween.js</exclude>
                    <exclude>**/src/ui/public/js/jquery.mustache.js</exclude>
                    <exclude>**/src/ui/public/js/purl.js</exclude>

                    <!-- generated by shade plugin -->
                    <exclude>**/dependency-reduced-pom.xml</exclude>
                </excludes>
            </configuration>
        </plugin>
    </plugins>
</reporting>

1 个答案:

答案 0 :(得分:1)

首先,您必须已安装Java 7。

所示

[警告] org.apache.maven.plugins的'reporting.plugins.plugin.version':缺少maven-javadoc-plugin。 @ org.apache.storm:storine:0.9.3,/home/user/.m2/repository/org/apache/storm/storm/0.9.3/storm-0.9.3.pom,line 694,column 21 [警告] org.apache.maven.plugins的'reporting.plugins.plugin.version':缺少maven-surefire-report-plugin。 @ org.apache.storm:storine:0.9.3,/home/user/.m2/repository/org/apache/storm/storm/0.9.3/storm-0.9.3.pom,第660行,第21栏

转到您的主目录并cd到/.m2/repository/org/apache/storm/storm/0.9.3/然后是nano或vi storm-0.9.3.pom。

搜索

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
            <source>1.6</source>
            <target>1.6</target>
        </configuration>
    </plugin>
如果你打算使用java-7-oracle,

将1.6修改为1.7。如果您使用的是nano,则可以使用 Ctrl + W <source>1.6</source>轻松搜索