我想在配置服务器中使用私有git存储库。这是我的应用程序属性:
spring.application.name=PhotoAppApiConfigServer
server.port=8012
spring.cloud.config.server.git.uri=https://github.com/nasrouu/PhotoAppConfiguration.git
spring.cloud.config.server.git.username=myusername
spring.cloud.config.server.git.password=mypassword
spring.cloud.config.server.git.clone-on-start=true
spring.cloud.config.server.git.default-label=main
management.endpoints.web.exposure.include=busrefresh
spring.rabbitmq.host=localhost
spring.rabbitmq.port=5672
spring.rabbitmq.username=guest
spring.rabbitmq.password=guest
我得到以下错误:
Error occured cloning to base directory
org.eclipse.jgit.api.errors.TransportException:
https://github.com/nasrouu/PhotoAppConfiguration.git: not authorized
我的私人github存储库的application.properties
gateway.ip=192.168.2.82
token.expiration_time=864000000
token.secret=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9eyJpZCI6IjVjOWYzYW
I2NzY2Mjg2NDYyNDY0YTczNCIsIm5hbWUiOiJSYW5keSIsImF2YXRhciI6I
i8vd3d3LmdyYXZhdGFyLmNvbS9hdmF0YXIvMTNhN2MyYzdkOGVk
NTNkMDc2MzRkOGNlZWVkZjM0NTEcz0yMDAmcj1wZyZkPW1tIiwi
aWF0IjoxNTU0NTIxNjk1LCJleHAiOjE1NTQ1MjUyOTV9SxRurShXSSI3SE11z6nme9EoaD2
9TDBFr8Qwngkg
login.url.path=/users/login
我该怎么修?
您必须创建一个个人访问令牌https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token
然后将生成的令牌作为del密钥复制到配置文件aplicación.propiedades中。例如:
spring.cloud.config.server.git.clone-on-start=true
spring.cloud.config.server.git.uri=https://github.com/joselizagaravito/RepositoryDemo
spring.cloud.config.server.git.username=myusername
spring.cloud.config.server.git.password=ghp_8ArBnIhaRUD4omMscbwOMydb4445556663
您还可以使用github和从github生成的新细粒度访问令牌来实现这一点。在这种情况下,用户名和密码都必须设置为生成的相同令牌。
spring:
application:
name: config-service
cloud:
config:
server:
git:
uri: https://github.com/UserName/PrivateRepo
username: github_fine_access_token_xxxx
password: github_fine_access_token_xxxx