有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java Apache Maven:Diamond运算符在源代码1.5中不受支持

我使用以下命令构建并运行Java Apache Camel代码

mvn clean compile camel:run

这个命令一直适用于我,但是当我有使用菱形运算符的代码时,我会得到一个错误

我的钻石操作员:

private List<RestPropertyDefinition> restProperties = new ArrayList<>();

我的错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project camel-rest-example: Compilation failure
[ERROR] /home/sindre/IdeaProjects/training/camelrestexample/src/main/java/com/test/EmployeeRoute.java:[21,73] diamond operator is not supported in -source 1.5
[ERROR]   (use -source 7 or higher to enable diamond operator)

我的POM文件:

<?xml version="1.0" encoding="UTF-8"?>
<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>

    <groupId>com.test</groupId>
    <artifactId>camel-rest-example</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencies>
        <!-- https://mvnrepository.com/artifact/org.apache.camel/camel-core -->
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-core</artifactId>
            <version>2.20.0</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.apache.camel/camel-spring -->
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-spring</artifactId>
            <version>2.20.0</version>
        </dependency>

        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>spi-annotations</artifactId>
            <version>2.20.0</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.apache.camel/camel-jms -->
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-jms</artifactId>
            <version>2.20.0</version>
        </dependency>

        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-http4</artifactId>
            <version>2.20.0</version>
        </dependency>

        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-quartz</artifactId>
            <version>2.20.0</version>
        </dependency>


        <!-- https://mvnrepository.com/artifact/org.apache.activemq/activemq-all -->
        <dependency>
            <groupId>org.apache.activemq</groupId>
            <artifactId>activemq-all</artifactId>
            <version>5.15.1</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-log4j12 -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.25</version>
            <scope>test</scope>
        </dependency>


    </dependencies>


    <build>
        <plugins>
            <!-- Allows the routes to be run via 'mvn camel:run' -->
            <plugin>
                <groupId>org.apache.camel</groupId>
                <artifactId>camel-maven-plugin</artifactId>
                <version>2.20.0</version>
            </plugin>
        </plugins>
    </build>
</project>

我正在使用Ubunut 18.04上的Java8和IntelliJ IDEA。看起来IntelliJ相信我在使用Java 5?但我的机器上只安装了Java8


共 (0) 个答案