zoukankan      html  css  js  c++  java
  • Maven maven-compiler-plugin 编译问题

    问题:每次右键项目名-maven->update project 时候,项目jdk版本变了,变回1.5版本或者其他版本

    解决方案一:修改maven的配置(解压目录的confsetting.xml文件)

    <profile>
        <id>jdk1.6</id>
        <activation>
            <activeByDefault>true</activeByDefault>
            <jdk>1.6</jdk>
        </activation>
        <properties>
            <!-- want to use the Java 8 language features, Default 1.5 -->
            <maven.compiler.source>1.6</maven.compiler.source>
            <!-- want the compiled classes to be compatible with JVM 1.8, Default 1.5 -->
            <maven.compiler.target>1.6</maven.compiler.target>
            <!-- Version of the compiler to use, ex. "1.3", "1.5", if fork is set to true -->
            <maven.compiler.compilerVersion>1.6</maven.compiler.compilerVersion>
        </properties>
    </profile> 

    解决方案二:默认settigs.xml文件路径为:c:usersxxx.m2settings.xml,只要把设置好的settings.xml文件复制到该目录下

    解决方案三:修改项目中的pom.xml

    <plugins>
        <!--
            指定maven插件编译版本
            1:maven:since2.0, 默认用jdk1.3来编译,maven 3.x 貌似是默认用jdk 1.52:windows默认使用GBK编码,java项目经常编码为utf8,也需要在compiler插件中指出,否则中文乱码可能会出现编译错误。 
         -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <!-- since 2.0 -->
            <version>3.7.0</version>
            <configuration>
                <!-- use the Java 8 language features -->
                <source>1.8</source>
                <!-- want the compiled classes to be compatible with JVM 1.8 -->
                <target>1.8</target>
                <!-- The -encoding argument for the Java compiler. -->
                <encoding>UTF8</encoding>
            </configuration>
        </plugin>
    </plugins>
  • 相关阅读:
    线上查询及帮助命令:
    windows: 2.7 3.5 (主要)
    get the execution time of a sql statement.
    java-kafka安装以及使用案例
    java-黑马头条 weex前端路由
    MYSQL安装
    缓存
    Flask中current_app和g对象
    [ValueError: signal only works in main thread]
    Flask-SQLAlchemy操作
  • 原文地址:https://www.cnblogs.com/zxguan/p/7847105.html
Copyright © 2011-2022 走看看