<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                [TOC] # git-commit-id-plugin ## 簡介 [https://github.com/git-commit-id/maven-git-commit-id-plugin](https://github.com/git-commit-id/maven-git-commit-id-plugin) 將以下內容添加到*POM*文件的插件部分??: ~~~ <plugin> <groupId>pl.project13.maven</groupId> <artifactId>git-commit-id-plugin</artifactId> <version>2.2.4</version> <executions> <execution> <id>get-the-git-infos</id> <goals> <goal>revision</goal> </goals> </execution> </executions> <configuration> <dotGitDirectory>${project.basedir}/.git</dotGitDirectory> <prefix>git</prefix> <verbose>false</verbose> <generateGitPropertiesFile>true</generateGitPropertiesFile> <generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename> <format>json</format> <gitDescribe> <skip>false</skip> <always>false</always> <dirty>-dirty</dirty> </gitDescribe> </configuration> </plugin> ~~~ 運行Maven build命令構建。在目錄??target / classes中,??git.properties文件添加了JSON格式的版本信息 ~~~ { "git.branch" : "master", "git.build.host" : "LT0265", "git.build.time" : "2018-01-21T17:34:26+0100", "git.build.user.email" : "gunter@mydeveloperplanet.com", "git.build.user.name" : "Gunter Rotsaert", "git.build.version" : "1.0-SNAPSHOT", "git.closest.tag.commit.count" : "", "git.closest.tag.name" : "", "git.commit.id" : "6f592254e2e08d99a8145f1295d4ba3042310848", "git.commit.id.abbrev" : "6f59225", "git.commit.id.describe" : "6f59225-dirty", "git.commit.id.describe-short" : "6f59225-dirty", "git.commit.message.full" : "Created basic Spring Boot application with webservice for retrieving hard-coded version information", "git.commit.message.short" : "Created basic Spring Boot application with webservice for retrieving hard-coded version information", "git.commit.time" : "2018-01-21T17:33:13+0100", "git.commit.user.email" : "gunter@mydeveloperplanet.com", "git.commit.user.name" : "Gunter Rotsaert", "git.dirty" : "true", "git.remote.origin.url" : "https://github.com/mydeveloperplanet/mygitcommitidplanet.git", "git.tags" : "" } ~~~ 現在仔細看看??mygitcommitidplanet-1.0-SNAPSHOT.jar文件。在目錄??BOOT-INF/?classes中,文件??git.properties可用。在這一點上,我們已經擁有了我們想要的:版本信息包含在我們的可交付成果中。我們總是可以查看??*JAR*文件來查找源代碼的確切版本信息。 ## 將版本信息添加到REST風格的Web服務 下一步是將我們的REST風格的Web服務中的硬編碼版本信息替換為git.properties文件的內容??。由于??git.properties文件已經是JSON格式,我們唯一要做的就是讀取文件的內容并將其返回到我們的Web服務中。 我們的??VersionController.java?文件變成以下內容: ~~~ @RequestMapping(value = "/version", method = GET) public String versionInformation() { return readGitProperties(); } private String readGitProperties() { ClassLoader classLoader = getClass().getClassLoader(); InputStream inputStream = classLoader.getResourceAsStream("git.properties"); try { return readFromInputStream(inputStream); } catch (IOException e) { e.printStackTrace(); return "Version information could not be retrieved"; } } private String readFromInputStream(InputStream inputStream) throws IOException { StringBuilder resultStringBuilder = new StringBuilder(); try (BufferedReader br = new BufferedReader(new InputStreamReader(inputStream))) { String line; while ((line = br.readLine()) != null) { resultStringBuilder.append(line).append("\n"); } } return resultStringBuilder.toString(); } ~~~ 使用Maven構建并運行應用程序。再次,轉到URL`?http://localhost:8080/version`。顯示我們的*git.properties*文件的內容??。 這正是我們想要的:版本信息可以隨時檢索并始終保持最新。如果您有客戶端應用程序,例如瀏覽器應用程序,則可以在關于部分中輕松使用此信息。 ## 驗證git屬性 ?當您想限制格式時,也可以將驗證添加到??*git.properties*文件。如果構建不符合驗證配置,構建將失敗。我們現在要添加一個驗證,以便在存儲庫變臟時讓構建失敗。 首先,我們在我們的*pom.xml?*文件的*配置*部分??添加一個??*ValidationProperties*部分??: ~~~ <validationProperties> <!-- verify that the current repository is not dirty --> <validationProperty> <name>validating git dirty</name> <value>${git.dirty}</value> <shouldMatchTo>false</shouldMatchTo> </validationProperty> </validationProperties> ~~~ 其次,我們必須激活驗證。這是在?git-commit-id插件的*執行*部分完成的??: ~~~ <execution> <id>validate-the-git-infos</id> <goals> <goal>validateRevision</goal> </goals> <phase>package</phase> </execution> ~~~ 我沒有提交我對*pom.xml?*文件所做的更改??,所以我的存儲庫很臟。使用Maven構建應用程序。正如所料,構建失敗并出現以下錯誤: ~~~ Validation 'validating git dirty' failed! Expected 'true' to match with 'false'! ~~~ 如果我們現在將*shouldMatchTo*更改??為??*true*并再次運行構建,則構建會成功。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看