zoukankan      html  css  js  c++  java
  • Error:(xx) java: -source 1.5 中不支持

    idea有两种打包方式,一种是打分散包(不包含第三方依赖,通过manifest文件中的classpath属性引用),一种是独立的包(包含所有的依赖),一直想打一个独立的包,无奈折腾了一天都搞不定,总结出了这个是idea的bug。所以目光转向了maven的Assembly Plugin 。

    下面是pom中build标签的配置,可以看到我设置了compolie为8

        <build>
            <plugins>
                <!--maven-assembly-plugin 打包-->
                <plugin>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>2.4</version>
                    <configuration>
                        <source>8</source>
                        <compolie>8</compolie>
                        <descriptorRefs>
                            <descriptorRef>jar-with-dependencies</descriptorRef>
                        </descriptorRefs>
                        <archive>
                            <manifest>
                                <mainClass>workmode.simplequeues.Consumer</mainClass>
                            </manifest>
                        </archive>
                    </configuration>
                    <executions>
                        <execution>
                            <id>make-assembly</id>
                            <phase>package</phase>
                            <goals>
                                <goal>single</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>

    下面的地方不忘记改成jar,不然不会把自身打包进去

    下面是报错:

    i检查idea中Java Compolier配置,编译版本为8

     检查idea中module设置 ,语言版本为8

     那个这个错误的1.5版本哪里来的呢?突然想到了maven的setting.xml配置文件,看了下,里面没有配置java版本。我们在setting.xml中profiles标签加入下面的配置

    <profile>  
          <id>jdk-1.8</id>  
          <activation>  
              <activeByDefault>true</activeByDefault>  
              <jdk>1.8</jdk>  
          </activation>  
          <properties>  
              <maven.compiler.source>1.8</maven.compiler.source>  
              <maven.compiler.target>1.8</maven.compiler.target>  
              <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>  
          </properties>   
    </profile>

    我们在maven package一下

     成功!

  • 相关阅读:
    session
    .net core 入坑经验
    .net core 入坑经验
    .net core 入坑经验
    一段刚刚出炉的CSV文件转换为DataTable对象的代码
    Github的一般用法
    SQLite简单使用记录
    一次SQLServer数据库宕机问题
    B样条基函数(cubic spline basis)
    matlab使用
  • 原文地址:https://www.cnblogs.com/crelle/p/13927136.html
Copyright © 2011-2022 走看看