The expression ${build.finalName} is deprecated. Please use ${project.build.finalName} instead.


障害の背景
今日はmaven Jettyプラグインを使用してwarプロジェクトを起動してみましょう.mavenのコマンドを実行しても、このような警告メッセージが表示されます.
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for com.xingyun:hello-world-sample:war:1.0-SNAPSHOT
[WARNING] The expression ${build.finalName} is deprecated. Please use ${project.build.finalName} instead.
[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] 

こしょうぶんせき
ヒントから見ると
The expression ${build.finalName} is deprecated. Please use ${project.build.finalName} instead.

つまり、${build.finalName}式は古いので、${project.build.finalName}で代用してください.
でもいったいどこを直すべきなのか???
私は長い間探していたが,いったいどこを修正すべきか見つからなかった.
今夜になって、偶然答えを见つけた.ここにあったのか...
<contextPath>/${build.finalName}contextPath>

前のエラーpom.xmlは次のようになります.

<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.0modelVersion>

    
    <groupId>com.xingyungroupId>
    <artifactId>hello-world-sampleartifactId>
    <version>1.0-SNAPSHOTversion>
    <packaging>warpackaging>

    <properties>
        
        <project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
        
        <java.version>12java.version>
        <maven.compiler.source>${java.version}maven.compiler.source>
        <maven.compiler.target>${java.version}maven.compiler.target>
        <maven.compiler.plugin.version>3.8.1maven.compiler.plugin.version>
        
        <skipTests>trueskipTests>
        
        <jetty.maven.plugin.version>9.4.7.v20170914jetty.maven.plugin.version>
    properties>

    <build>
        
        <finalName>hello-world-samplefinalName>
        
        <plugins>
            
            <plugin>
                <groupId>org.eclipse.jettygroupId>
                <artifactId>jetty-maven-pluginartifactId>
                <version>${jetty.maven.plugin.version}version>
                <configuration>
                    <webApp>
                        <contextPath>/${build.finalName}contextPath>
                    webApp>
                    <stopKey>CTRL+CstopKey>
                    <stopPort>8999stopPort>
                    <scanIntervalSeconds>10scanIntervalSeconds>
                    <scanTargets>
                        <scanTarget>src/main/webapp/WEB-INF/web.xmlscanTarget>
                    scanTargets>
                configuration>
            plugin>
            
            
            <plugin>
                <groupId>org.apache.maven.pluginsgroupId>
                <artifactId>maven-compiler-pluginartifactId>
                <version>${maven.compiler.plugin.version}version>
                <configuration>
                    <source>${java.version}source>
                    <target>${java.version}target>
                configuration>
            plugin>
        plugins>
    build>
project>

修復ソリューション
修復に成功したpom.xmlの構成は次のとおりです.

<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.0modelVersion>

    
    <groupId>com.xingyungroupId>
    <artifactId>hello-world-sampleartifactId>
    <version>1.0-SNAPSHOTversion>
    <packaging>warpackaging>

    <properties>
        
        <project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
        
        <java.version>12java.version>
        <maven.compiler.source>${java.version}maven.compiler.source>
        <maven.compiler.target>${java.version}maven.compiler.target>
        <maven.compiler.plugin.version>3.8.1maven.compiler.plugin.version>
        
        <skipTests>trueskipTests>
        
        <jetty.maven.plugin.version>9.4.7.v20170914jetty.maven.plugin.version>
    properties>

    <build>
        
        <finalName>hello-world-samplefinalName>
        
        <plugins>
            
            <plugin>
                <groupId>org.eclipse.jettygroupId>
                <artifactId>jetty-maven-pluginartifactId>
                <version>${jetty.maven.plugin.version}version>
                <configuration>
                    <webApp>
                        <contextPath>/${project.build.finalName}contextPath>
                    webApp>
                    <stopKey>CTRL+CstopKey>
                    <stopPort>8999stopPort>
                    <scanIntervalSeconds>10scanIntervalSeconds>
                    <scanTargets>
                        <scanTarget>src/main/webapp/WEB-INF/web.xmlscanTarget>
                    scanTargets>
                configuration>
            plugin>
            
            
            <plugin>
                <groupId>org.apache.maven.pluginsgroupId>
                <artifactId>maven-compiler-pluginartifactId>
                <version>${maven.compiler.plugin.version}version>
                <configuration>
                    <source>${java.version}source>
                    <target>${java.version}target>
                configuration>
            plugin>
        plugins>
    build>
project>

Tips:hello-world-sampleを設定しないと何が起こるか気になったことがありますか.
  • この属性を設定しない場合、デフォルトの/${project.build.finalName}の値はartifactid+versionが結合した結果になります.http://127.0.0.1:8080/hello-world-sample-1.0-SNAPSHOT
  • 上記のように設定するとこうなりますhttp://127.0.0.1:8080/hello-world-sample