目前,我们正在使用Apache v4.2.8安装/运行作为一个windows服务。
我们使用AWS代码伪码作为mvn存储库,这里的问题是令牌只持续12小时--这意味着每次我们需要使用新令牌时,我们都需要重新启动windows service / karaf,以便它能够正确地获取令牌并进行身份验证(如果需要安装新功能,只会出现问题)。
我是不是漏掉了什么?有没有一种使用环境变量的方法?
发布于 2022-04-29 15:23:24
Karaf包含可以安装以管理Maven存储库的maven特性:
karaf@root()> feature:install maven例如:
karaf@root()> maven:repository-list
== Remote repositories
ID │ URL
────────────────────────────────┼───────────────────────────────────────────────────────────────
central │ https://repo1.maven.org/maven2/
apache │ https://repository.apache.org/content/groups/snapshots-group/
ops4j.sonatype.snapshots.deploy │ https://oss.sonatype.org/content/repositories/ops4j-snapshots/
== Default repositories
ID │ URL
────────────────────────┼────────────────────────────────────────────────
system.repository │ file:/data/servers/apache-karaf-4.3.6/system/
kar.repository │ file:/data/servers/apache-karaf-4.3.6/data/kar/
child.system.repository │ file:/data/servers/apache-karaf-4.3.6/system/您可以使用maven:repository-change命令更改任何远程maven存储库的配置。
默认情况下,Maven主密码(参见mvn -emp)是从~/.m2/settings-security.xml中提取的,但是如果调用maven:password -emp -p,您可以设置新的主密码,并且在Karaf下面将创建新的settings-security.xml,并将etc/org.ops4j.pax.url.mvn.cfg指向该文件。例如:
karaf@root()> maven:password -emp -p
Maven security settings will be stored in new file. This file will be used in org.ops4j.pax.url.mvn.security property. Continue? (y/N) y
Master password to encrypt: ********
Encrypted master password: {xxx}
New security settings stored in "/data/servers/apache-karaf-4.3.6/data/cache/bundle52/data/maven-security-settings-1651245247562.xml"maven-security-settings-1651245247562.xml看起来是这样的:
$ cat /data/servers/apache-karaf-4.3.6/data/cache/bundle52/data/maven-security-settings-1651245247562.xml
<?xml version="1.0" encoding="UTF-8"?>
<settingsSecurity>
<master>{xxx}</master>
</settingsSecurity>etc/org.ops4j.pax.url.mvn.cfg包含两个新属性:
org.ops4j.pax.url.mvn.settings = /data/servers/apache-karaf-4.3.6/data/cache/bundle52/data/maven-settings-1651244980542.xml
org.ops4j.pax.url.mvn.security = /data/servers/apache-karaf-4.3.6/data/cache/bundle52/data/maven-security-settings-1651245247562.xml第二个包含新的主密码,第一个是现有~/.m2/settings.xml的副本。
您可以使用以下方法更改存储库密码:
karaf@root()> maven:repository-change -id central --username test --password test
Maven settings will be updated and org.ops4j.pax.url.mvn.settings property will change. Continue? (y/N) y
New settings stored in "/data/servers/apache-karaf-4.3.6/data/cache/bundle52/data/maven-settings-1651245438306.xml"创建了maven-settings-1651245438306.xml,Maven Central现在看起来如下所示:
<server>
<username>test</username>
<password>test</password>
<id>central</id>
</server>您也可以使用加密密码。首先获得它:
karaf@root()> maven:password -ep
Password to encrypt: ****
Encrypted password: {xxx}
You can use this encrypted password when defining repositories and proxies并使用它:
karaf@root()> maven:repository-change -id central --username test --password '{xxx}'
Maven settings will be updated and org.ops4j.pax.url.mvn.settings property will change. Continue? (y/N) y
New settings stored in "/data/servers/apache-karaf-4.3.6/data/cache/bundle52/data/maven-settings-1651245586888.xml"感谢前面创建的主密码,一切都很好:
karaf@root()> maven:repository-list -x
== Remote repositories
ID │ URL │ Username │ Password
────────────────────────────────┼────────────────────────────────────────────────────────────────┼──────────┼─────────
central │ https://repo1.maven.org/maven2/ │ test │ testmaven-settings-1651245586888.xml包含:
<server>
<username>test</username>
<password>{xxx}</password>
<id>central</id>
</server>这些命令简单地操作配置管理和org.ops4j.pax.url.mvn PID。但它们让您在底层透明地处理settings.xml。
请参阅有关Karaf命令的文档:https://karaf.apache.org/manual/latest/#_maven_configuration_commands
https://stackoverflow.com/questions/72059631
复制相似问题