• pom.xml中的maven.compiler.source和maven.compiler.target作用


    【形式】

        <properties>
            <maven.compiler.source>8</maven.compiler.source>
            <maven.compiler.target>8</maven.compiler.target>
        </properties>

    【作用】

    pom.xml中的maven.compiler.source和maven.compiler.是用来编译源码和打包的,通常它们的版本等于系统JDK的大版本,如11,9,8...;

    如果不能控制客户机的jdk,而想让包的适用性更广的话,可以手动降低版本号,比如如从11降到8;

    如此做了后,在别的机器上运行自己的jar,就不会爆jdk版本低的错误。

    举例来说,我之前使用11打了个jar包,放到jdk=9的虚拟机上没法用,于是手动降低到8,因为代码中也确实没用到8后继版本的特性,于是再次打包后,虚拟机上再运行就可以了。

    【在pom中的位置】

    这里把maven.compiler.source和maven.compiler.target的位置贴出来,粗体部分就是位置所在。

    <?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>org.example</groupId>
        <artifactId>JsonPretty</artifactId>
        <version>1.00</version>
    
        <properties>
            <maven.compiler.source>8</maven.compiler.source>
            <maven.compiler.target>8</maven.compiler.target>
        </properties>
    
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter</artifactId>
                <version>2.6.4</version>
            </dependency>
    
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-webmvc</artifactId>
                <version>5.3.16</version>
            </dependency>
    
            <dependency>
                <groupId>commons-lang</groupId>
                <artifactId>commons-lang</artifactId>
                <version>2.6</version>
            </dependency>
        </dependencies>
    
        <build>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <executions>
                        <execution>
                            <goals>
                                <goal>repackage</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </project>

    END

  • 相关阅读:
    使用tornado的gen模块改善程序性能
    分析Linux内核中进程的调度(时间片轮转)-《Linux内核分析》Week2作业
    博客园配置MarsEdit客户端
    分析一个C语言程序生成的汇编代码-《Linux内核分析》Week1作业
    微信支付的开发流程
    探究加法操作的原子性
    mac下mysql数据库的配置
    从range和xrange的性能对比到yield关键字(中)
    使用装饰器时带括号与不带括号的区别
    从range和xrange的性能对比到yield关键字(上)
  • 原文地址:https://www.cnblogs.com/heyang78/p/15999421.html
Copyright © 2020-2023  润新知