git hok json_从战中反弹:将Git提交信息作为JSON返回

git hok json

在某些情况下,我们必须知道部署到远程服务器的Web应用程序的确切版本。 例如,客户可能想知道我们是否已经在服务器X上部署了错误修复程序。

当然,我们可以尝试使用“传统”方法找到该问题的答案。 问题是:

  • 没有人不记得是谁更新了服务器X或何时更新了服务器X。
  • 更新它的人不记得哪个是构建中包含的最后一次提交。

换句话说,我们被搞砸了。 我们可以尝试测试服务器X上是否仍然存在该错误,但这对我们没有帮助,因为我们的错误修复可能无法正常工作。

这篇博客文章描述了我们如何解决这个问题。 让我们从提取Git存储库的构建时状态开始。

如果使用Spring Boot,则应使用Spring Boot Actuator 。 它可以帮助您发布有关Git存储库状态的信息 。

如果您尚未阅读以下博客文章, 则应先阅读它们,然后再继续阅读此博客文章

  • 从槽中弹起:将属性值注入配置Bean描述了为什么应将属性值注入配置Bean并帮助您做到这一点。
  • 从槽中弹跳:以JSON返回运行时配置描述了如何将Web应用程序的运行时配置写入日志文件并将其作为JSON返回。

提取我们的Git仓库的构建时间状态

我们可以使用Maven Git Commit Id插件提取Git存储库的构建时状态。 让我们了解如何配置Maven Git Commit Id插件并将提取的信息添加到属性文件中。

首先 ,我们需要配置资源目录的位置,并确保将从属性文件中找到的属性占位符替换为实际的属性值。 我们可以通过将以下XML添加到pom.xml文件的build部分中来实现:

<resources><resource><directory>src/main/resources</directory><filtering>true</filtering><includes><include>**/*.properties</include></includes></resource>
</resources>

其次 ,我们需要配置Maven Git Commit Id插件。 我们可以按照以下步骤进行操作:

  1. 将Maven Git提交ID插件添加到我们的构建中。
  2. 确保在默认生命周期的初始化阶段调用了Maven Git Commit Id插件的修订目标。
  3. 配置.git目录的位置。

我们需要将以下XML添加到pom.xml文件的plugins部分:

<plugin><groupId>pl.project13.maven</groupId><artifactId>git-commit-id-plugin</artifactId><version>2.1.13</version><!--Ensure that the revision goal is invoked during the initializephase.--><executions><execution><goals><goal>revision</goal></goals></execution></executions><configuration><!--Configure the location of the .git directory.--><dotGitDirectory>${project.basedir}/../.git</dotGitDirectory></configuration>
</plugin>

如果您对Maven Git Commit Id插件的默认配置不满意,则应仔细阅读其自述文件:

  • 使用该插件提供了带注释的XML配置文件,该文件描述了Maven Git Commit Id插件的配置。
  • 深入的配置选项描述了Maven Git Commit Id插件的每个配置选项。

第三 ,我们需要创建属性文件,其中包含从Git存储库中提取的信息。 application.properties文件如下所示:

git.tags=${git.tags}
git.branch=${git.branch}
git.dirty=${git.dirty}
git.remote.origin.url=${git.remote.origin.url}git.commit.id=${git.commit.id}
git.commit.id.abbrev=${git.commit.id.abbrev}
git.commit.id.describe=${git.commit.id.describe}
git.commit.id.describe-short=${git.commit.id.describe-short}
git.commit.user.name=${git.commit.user.name}
git.commit.user.email=${git.commit.user.email}
git.commit.message.full=${git.commit.message.full}
git.commit.message.short=${git.commit.message.short}
git.commit.time=${git.commit.time}git.build.user.name=${git.build.user.name}
git.build.user.email=${git.build.user.email}
git.build.time=${git.build.time}

现在,我们已经配置了Maven Git Commit Id插件。 编译项目时,将从application.properties文件中找到的属性占位符替换为从Git存储库中提取的实际属性值。

target / classes目录中找到的application.properties文件如下所示:

git.tags=
git.branch=master
git.dirty=true
git.remote.origin.url=git@github.com:pkainulainen/spring-from-the-trenches.gitgit.commit.id=1bdfe9cf22b550a3ebe170f60df165e5c26448f9
git.commit.id.abbrev=1bdfe9c
git.commit.id.describe=1bdfe9c-dirty
git.commit.id.describe-short=1bdfe9c-dirty
git.commit.user.name=Petri Kainulainen
git.commit.user.email=petri.kainulainen@gmail.com
git.commit.message.full=Declare PropertySourcesPlaceholderConfigurer in a static @Bean method
git.commit.message.short=Declare PropertySourcesPlaceholderConfigurer in a static @Bean method
git.commit.time=16.04.2015 @ 23:35:23 EESTgit.build.user.name=Petri Kainulainen
git.build.user.email=petri.kainulainen@gmail.com
git.build.time=18.04.2015 @ 17:07:55 EEST

如果您不想创建属性文件,则Maven Git Commit Id插件可以为您生成一个 。

让我们继续前进,找出如何将Git提交信息注入到属性bean中。

将Git提交信息注入到属性Bean中

我们需要创建以下描述的三个属性bean类:

  • BuildProperties类包含有关开始构建的人的信息。
  • CommitProperties类包含有关构建中包含的最新提交的信息。
  • GitProperties类包含一些“公共”属性,例如branchtagsremoteOriginUrl 。 它还包含对BuildPropertiesCommitProperties对象的引用。

属性Bean与以下内容中描述的配置Bean相似
我以前的博客文章 。 我为这些类使用不同的后缀的原因是,它们不是Web应用程序配置的一部分。 它们仅包含写入日志文件并以JSON返回的信息。

另外,如果您不知道为什么要将属性值注入特殊的bean类中以及如何将其值注入,则应阅读我的博客文章,该文章回答了这两个问题 。

首先 ,我们需要创建BuildProperties类。 此类具有final timeuserEmailuserName字段。 通过使用构造函数注入将实际字段值注入到这些字段中。 BuildProperties类的源代码如下所示:

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;@Component
public class BuildProperties {private final String time;private final String userEmail;private final String userName;@Autowiredpublic BuildProperties(@Value("${git.build.time}") String time,@Value("${git.build.user.email}") String userEmail,@Value("${git.build.user.name}") String userName) {this.time = time;this.userEmail = userEmail;this.userName = userName;}//Getters are omitted for the sake of clarity
}

其次 ,我们需要创建CommitProperties类。 此类具有最后的describedescribeShortfullMessageididAbbrevshortMessagetimeuserEmailuserName字段。 通过使用构造函数注入将实际属性值注入到这些字段中。 CommitProperties类的源代码如下所示:

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;@Component
public class CommitProperties {private final String describe;private final String describeShort;private final String fullMessage;private final String id;private final String idAbbrev;private final String shortMessage;private final String time;private final String userEmail;private final String userName;@Autowiredpublic CommitProperties(@Value("${git.commit.id.describe}") String describe,@Value("${git.commit.id.describe-short}") String describeShort,@Value("${git.commit.message.full}") String fullMessage,@Value("${git.commit.id}") String id,@Value("${git.commit.id.abbrev}") String idAbbrev,@Value("${git.commit.message.short}") String shortMessage,@Value("${git.commit.time}") String time,@Value("${git.commit.user.email}") String userEmail,@Value("${git.commit.user.name}") String userName) {this.describe = describe;this.describeShort = describeShort;this.fullMessage = fullMessage;this.id = id;this.idAbbrev = idAbbrev;this.shortMessage = shortMessage;this.time = time;this.userEmail = userEmail;this.userName = userName;}//Getters are omitted for the sake of clarity
}

第三 ,我们需要创建GitProperties类。 此类具有最后的branchbuildcommitdirtyremoteOriginUrltags字段。 通过使用构造函数注入将实际字段值(或对象)注入这些字段。 GitProperties类的源代码如下所示:

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;@Component
public class GitProperties {private String branch;private final BuildProperties build;private final CommitProperties commit;private final boolean dirty;private final String remoteOriginUrl;private final String tags;@Autowiredpublic GitProperties(@Value("${git.branch}") String branch,BuildProperties build,CommitProperties commit,@Value("${git.dirty}") boolean dirty,@Value("${git.remote.origin.url}") String remoteOriginUrl,@Value("${git.tags}") String tags) {this.branch = branch;this.build = build;this.commit = commit;this.dirty = dirty;this.remoteOriginUrl = remoteOriginUrl;this.tags = tags;}//Getters are omitted for the sake of clarity
}

让我们继续并将Git提交信息写入日志文件。

将Git提交信息写入日志文件

下一步是将Git提交信息信息写入日志文件。 让我们找出如何做到这一点。

首先 ,我们必须向BuildPropertiesCommitPropertiesGitProperties类添加toString()方法,并使用ToStringBuilder类实现这些方法。

BuildProperties类的源代码如下所示:

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;@Component
public class BuildProperties {private final String time;private final String userEmail;private final String userName;@Autowiredpublic BuildProperties(@Value("${git.build.time}") String time,@Value("${git.build.user.email}") String userEmail,@Value("${git.build.user.name}") String userName) {this.time = time;this.userEmail = userEmail;this.userName = userName;}//Getters are omitted for the sake of clarity@Overridepublic String toString() {return new ToStringBuilder(this).append("time", this.time).append("userEmail", this.userEmail).append("userName", this.userName).toString();}
}

CommitProperties类的源代码如下所示:

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;@Component
public class CommitProperties {private final String describe;private final String describeShort;private final String fullMessage;private final String id;private final String idAbbrev;private final String shortMessage;private final String time;private final String userEmail;private final String userName;@Autowiredpublic CommitProperties(@Value("${git.commit.id.describe}") String describe,@Value("${git.commit.id.describe-short}") String describeShort,@Value("${git.commit.message.full}") String fullMessage,@Value("${git.commit.id}") String id,@Value("${git.commit.id.abbrev}") String idAbbrev,@Value("${git.commit.message.short}") String shortMessage,@Value("${git.commit.time}") String time,@Value("${git.commit.user.email}") String userEmail,@Value("${git.commit.user.name}") String userName) {this.describe = describe;this.describeShort = describeShort;this.fullMessage = fullMessage;this.id = id;this.idAbbrev = idAbbrev;this.shortMessage = shortMessage;this.time = time;this.userEmail = userEmail;this.userName = userName;}//Getters are omitted for the sake of clarity@Overridepublic String toString() {return new ToStringBuilder(this).append("describe", this.describe).append("describeShort", this.describeShort).append("fullMessage", this.fullMessage).append("id", this.id).append("idAbbrev", this.idAbbrev).append("shortMessage", this.shortMessage).append("time", this.time).append("userEmail", this.userEmail).append("userName", this.userName).toString();}
}

GitProperties类的源代码如下所示:

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;@Component
public class GitProperties {private String branch;private final BuildProperties build;private final CommitProperties commit;private final boolean dirty;private final String remoteOriginUrl;private final String tags;@Autowiredpublic GitProperties(@Value("${git.branch}") String branch,BuildProperties build,CommitProperties commit,@Value("${git.dirty}") boolean dirty,@Value("${git.remote.origin.url}") String remoteOriginUrl,@Value("${git.tags}") String tags) {this.branch = branch;this.build = build;this.commit = commit;this.dirty = dirty;this.remoteOriginUrl = remoteOriginUrl;this.tags = tags;}//Getters are omitted for the sake of clarity@Overridepublic String toString() {return new ToStringBuilder(this).append("branch", this.branch).append("build", this.build).append("commit", this.commit).append("dirty", this.dirty).append("remoteOriginUrl", this.remoteOriginUrl).append("tags", this.tags).toString();}
}

其次 ,我们必须在启动应用程序时将Git提交信息写入日志文件。 我们可以按照以下步骤进行操作:

  1. 静态的最终Logger字段添加到GitProperties类,并使用LoggerFactory类创建一个新的Logger对象。
  2. writeGitCommitInformationToLog()方法添加到GitProperties类,并使用@PostConstruct批注对其进行批注。 这样可以确保Spring容器在将创建的bean对象的依赖项注入到其中之后调用此方法。
  3. 通过将Git提交信息写入日志文件来实现writeGitCommitInformationToLog()方法。

完成这些更改后, GitProperties类的源代码如下所示:

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;import javax.annotation.PostConstruct;@Component
public class GitProperties {private static final Logger LOGGER = LoggerFactory.getLogger(GitProperties.class);private String branch;private final BuildProperties build;private final CommitProperties commit;private final boolean dirty;private final String remoteOriginUrl;private final String tags;@Autowiredpublic GitProperties(@Value("${git.branch}") String branch,BuildProperties build,CommitProperties commit,@Value("${git.dirty}") boolean dirty,@Value("${git.remote.origin.url}") String remoteOriginUrl,@Value("${git.tags}") String tags) {this.branch = branch;this.build = build;this.commit = commit;this.dirty = dirty;this.remoteOriginUrl = remoteOriginUrl;this.tags = tags;}//Getters are omitted for the sake of clarity@Overridepublic String toString() {return new ToStringBuilder(this).append("branch", this.branch).append("build", this.build).append("commit", this.commit).append("dirty", this.dirty).append("remoteOriginUrl", this.remoteOriginUrl).append("tags", this.tags).toString();}@PostConstructpublic void writeGitCommitInformationToLog() {LOGGER.info("Application was built by using the Git commit: {}", this);}
}

启动Web应用程序时,我们应该从其日志文件中找到以下信息:

INFO  - GitProperties - Application was built by using the Git commit: net.petrikainulainen.spring.trenches.config.GitProperties@47044f7d[branch=master,build=net.petrikainulainen.spring.trenches.config.BuildProperties@7b14c61[time=19.04.2015 @ 00:47:37 EEST,userEmail=petri.kainulainen@gmail.com,userName=Petri Kainulainen],commit=net.petrikainulainen.spring.trenches.config.CommitProperties@8fcc534[describe=1bdfe9c-dirty,describeShort=1bdfe9c-dirty,fullMessage=Declare PropertySourcesPlaceholderConfigurer in a static @Bean method,id=1bdfe9cf22b550a3ebe170f60df165e5c26448f9,idAbbrev=1bdfe9c,shortMessage=Declare PropertySourcesPlaceholderConfigurer in a static @Bean method,time=16.04.2015 @ 23:35:23 EEST,userEmail=petri.kainulainen@gmail.com,userName=Petri Kainulainen],dirty=true,remoteOriginUrl=git@github.com:pkainulainen/spring-from-the-trenches.git,tags=
]

该信息写在一行中,但是我对它进行了格式化,因为我想使其更易于阅读。

让我们了解如何将Git提交信息作为JSON返回。

以JSON形式返回Git提交信息

之前,我们创建了一个控制器类 , 该类将Web应用程序的运行时配置作为JSON返回。 让我们修改此类以将Git提交信息作为JSON返回。 我们可以按照以下步骤进行操作:

  1. 最后的GitProperties字段添加到PropertiesController类。
  2. 使用构造函数注入将GitProperties bean注入到创建的控制器bean中。
  3. 创建一个控制器方法来处理发送到url'/ version'的GET请求,并通过返回GitProperties对象来实现它。

PropertiesController的源代码如下所示:

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;@RestController
final class PropertiesController {private final ApplicationProperties applicationProperties;private final GitProperties gitProperties;@AutowiredPropertiesController(ApplicationProperties applicationProperties, GitProperties gitProperties) {this.applicationProperties = applicationProperties;this.gitProperties = gitProperties;}@RequestMapping(value = "/config", method = RequestMethod.GET)ApplicationProperties getAppConfiguration() {return applicationProperties;}@RequestMapping(value = "/version", method = RequestMethod.GET)GitProperties getVersion() {return gitProperties;}
}

当我们将GET请求发送到url'/ version'时,我们的控制器方法将返回以下JSON:

{"branch":"master","build":{"time":"19.04.2015 @ 00:47:37 EEST","userEmail":"petri.kainulainen@gmail.com","userName":"Petri Kainulainen"},"commit":{"describe":"1bdfe9c-dirty","describeShort":"1bdfe9c-dirty","fullMessage":"Declare PropertySourcesPlaceholderConfigurer in a static @Bean method","id":"1bdfe9cf22b550a3ebe170f60df165e5c26448f9","idAbbrev":"1bdfe9c","shortMessage":"Declare PropertySourcesPlaceholderConfigurer in a static @Bean method","time":"16.04.2015 @ 23:35:23 EEST","userEmail":"petri.kainulainen@gmail.com","userName":"Petri Kainulainen"},"dirty":true,"remoteOriginUrl":"git@github.com:pkainulainen/spring-from-the-trenches.git","tags":""
}

我们不应该允许所有人访问我们应用程序的Git提交信息。 如果这将是一个真实的应用程序,我们应确保只有管理员才能访问此信息。

让我们继续并总结从这篇博客文章中学到的知识。

摘要

这篇博客文章教会了我们三件事:

  • 我们可以使用Maven Git Commit Id插件从Git存储库中提取构建时状态。
  • 我们可以通过重写属性bean类的toString()方法并将这些bean的属性值注入到日志文件中后,将Git提交信息写入日志文件。
  • 通过创建返回“根”属性bean对象( GitProperties )的控制器方法,我们可以将Git提交信息作为JSON返回。
  • PS:您可以从Github获得此博客文章的示例应用程序 。

翻译自: https://www.javacodegeeks.com/2015/04/spring-from-the-trenches-returning-git-commit-information-as-json.html

git hok json

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/337783.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

oracle plsql异常,【Oracle篇】异常处理和PLSQL

一、所有的PL/SQL异常都具有以下几个基本特征&#xff1a; 错误类型&#xff1a;表示了错误是ORA错误还是PLS错误 错误代号&#xff1a;一串表示错误代号的数字 错误文本&#xff1a;错误消息文本&#xff0c;包括错误代号 二、PL/SQL会产生两种类型的错误 &#xff1a; ORA错误…

如何把CPP源程序改写成C语言?

点击蓝字关注我们曾经参与过公司的bpp项目&#xff0c;就是bluetooth print profile。由于使用了hpijs的开源包&#xff0c;但是是C&#xff0b;&#xff0b;的。由于C&#xff0b;&#xff0b;解释器比C语言解释器占用的存储空间要大500k左右。为了节省有限的存储空间&#xf…

php cdi_使用Fabric8在CDI管理的bean中注入Kubernetes Services

php cdi序幕 我在Kubernetes中最喜欢的是发现服务的方式。 为什么&#xff1f; 主要是因为用户代码不必处理注册&#xff0c;查找服务&#xff0c;也没有网络意外&#xff08;如果您曾经尝试过基于注册表的方法&#xff0c;那么您就会知道我在说什么&#xff09; 。 这篇文章…

oracle日志恢复启用命令,oracle 日志恢复数据详解

1&#xff1a;首先查找redo&#xff0c;如果redo有可供恢复的信息&#xff0c;就那redo中的信息进行恢复&#xff0c;此时一般在恢复时&#xff0c;类似如下:SQL> recover database;Media recovery complete.2&#xff1a;如果在redo中没有找到可供恢复的信息&#xff0c;or…

9 个很酷的 CMD 命令

点击蓝字关注我们ipconfig功能&#xff1a;查询本机IP地址操作方法&#xff1a;只要在在打开的cmd命令界面中输入“ipconfig”就可以了。msg功能&#xff1a;向对方电脑发送一条文本提示操作方法&#xff1a;首先你要知道对方的IP地址&#xff0c;接下来输入命令“msg /server:…

使用java进行婚礼庆祝_#102030:在30天内运行20 10K,庆祝Java 20年

使用java进行婚礼庆祝1995年5月23日是技术史上的重要时刻。 业界似乎并未意识到当天发布的语言会在未来几年内完全改变技术的格局。 Java将在今年的同一天庆祝20岁生日。 Java 20年&#xff0c;哇&#xff01; 回顾20年前的存储器时代&#xff0c;思考一下Java的发明时间/方式…

oracle 插入出错_使用sqlca打印错误原因,ORACLE-Proc:SQLCA

SQL 通信区是用下列语句描述的&#xff1a;EXEC SQL INCLUDE SQLCA&#xff1b;此部分提供了用户运行程序的成败记录和错误处理。SQLCA的组成SQLCA是一个结构类型的变量&#xff0c;它是ORACLE 和应用程序的一个接口。在执行 Pro*C程序时&#xff0c; ORACLE 把每一个嵌入SQL语…

这几行 C++ 代码,真的骚!

点击蓝字关注我们事情是这么一回事&#xff1a;国外有个大佬在StackExchange上发起了一个叫做 Tweetable Mathematical Art 的比赛。参赛者需要用C编写代表三原色的RD、GR、BL三个函数&#xff0c;每个函数都不能超过 140 个字符。每个函数都会接到 i 和 j 两个整型参数&#x…

sts集成jboss_JBoss BPM Travel Agency演示与现代BPM数据集成

sts集成jboss不久前&#xff0c;我们启动了一个规模较大的JBoss Travel Agency演示项目&#xff0c;以展示JBoss BPM Suite的一些更有趣的功能。 我们提供了一系列视频 &#xff0c;不仅向您展示了如何安装它&#xff0c;项目中各种规则和流程工件的含义&#xff0c;还向您介绍…

详解C语言的C#数组

点击蓝字关注我们数组是一种存储相同类型元素的固定大小顺序集合。数组用于存储数据集合&#xff0c;但一般会将数组视为存储在连续存储器位置的相同类型的变量的集合。如果要存储表示100名称学生的分数&#xff0c;需要独立地声明100整数变量。例如&#xff1a;number0.number…

jdk注解_我们正在下注:这个注解很快就会出现在JDK中

jdk注解Yahor最近提出的Stack Overflow问题引起了我的兴趣&#xff1a; 如何在Java 8编译时确保方法签名“实现”功能接口 。 这是一个很好的问题。 让我们假设以下名义类型&#xff1a; FunctionalInterface interface LongHasher {int hash(long x); }该类型强加了清晰的合同…

oracle的连接函数,Oracle各种连接函数总结

1.前言Oracle可用连接函数会介绍以下几个Oracle列转行函数 Listagg()strcat()wmsys.wm_concat()2.Oracle列转行函数 Listagg()2.1最基础的用法&#xff1a;LISTAGG(XXX,XXX) WITHIN GROUP( ORDER BY XXX)用法就像聚合函数一样&#xff0c;通过Group by语句&#xff0c;把每个Gr…

抽象工厂模式设计模式_21世纪的设计模式:抽象工厂模式

抽象工厂模式设计模式这是我的演讲的第二部分&#xff0c;“ 21世纪的设计模式” 。 此模式在Java代码中到处都有使用&#xff0c;尤其是在更多“企业”代码库中。 它涉及一个接口和一个实现。 该界面如下所示&#xff1a; public interface Bakery {Pastry bakePastry(Toppi…

对 C 语言指针最详尽的讲解

点击蓝字关注我们指针对于C来说太重要。然而&#xff0c;想要全面理解指针&#xff0c;除了要对C语言有熟练的掌握外&#xff0c;还要有计算机硬件以及操作系统等方方面面的基本知识。所以本文尽可能的通过一篇文章完全讲解指针。为什么需要指针&#xff1f;指针解决了一些编程…

app http routes.php,Laravel:我的应用程序没有被路由(Laravel : My app doesn't get routed)

Laravel&#xff1a;我的应用程序没有被路由(Laravel : My app doesnt get routed)我正在运行我的第一个laravel应用程序&#xff0c;在接下来的几个小时中遇到依赖项安装错误。对不起它可能是一个小错误&#xff0c;但似乎我无法找到。图片较暗&#xff0c;电脑坏了。应用程序…

ssm 返回json配置_摆脱困境:将运行时配置作为JSON返回

ssm 返回json配置如果需要确定部署到远程服务器的Spring Web应用程序的运行时配置&#xff0c;则需要读取从远程服务器找到的属性文件。 这很麻烦。 幸运的是&#xff0c;有更好的方法。 这篇博客文章描述了我们如何 启动我们的Web应用程序时&#xff0c;将运行时配置写入日志…

为什么 Android 必须在主线程更新 UI ?

点击蓝字关注我们为什么Android必须在主线程更新UI&#xff1f;站在各位大牛的肩膀上&#xff0c;谢谢&#xff01;正常情况下&#xff0c;Android需要在UI线程更新UI&#xff0c;然鹅&#xff0c;在特殊情况下&#xff0c;子线程也能更新UI不在讨论之列&#xff0c;这篇文章主…

如何对linux文件进行编译,Linux下将源文件编译成目标文件的过程解析

简介请讲一下linux如何源文件逐步编译成可执行文件。解答首先先上图对编译的整个过程有个感性的认识&#xff0c;然后再逐步分析各个过程。以hello.c 程序为例# include main{printf("hello\n");}一个.c源程序需要经过预处理器生成.i文件&#xff0c;再经过编译器生成…

eclipse m2e配置_使用此首选项可加快Eclipse m2e配置

eclipse m2e配置谁不认识他们。 Eclipse中的旧式JFace对话框可以使您直观地看到实际上是一个相当简单的XML或属性文件。 对于m2e&#xff0c;它看起来像这样&#xff1a; 不幸的是&#xff0c;此屏幕的加载速度有点慢&#xff0c;除了检查版本号和其他您将永远不会更改的东西…

学点 STL C++ 的线性容器

点击蓝字关注我们std::array看到这个容器的时候肯定会出现这样的问题&#xff1a;为什么要引入 std::array 而不是直接使用 std::vector&#xff1f;已经有了传统数组&#xff0c;为什么要用 std::array?先回答第一个问题&#xff0c;与 std::vector 不同&#xff0c;std::arr…