[英]Intellij 2021 Cannot resolve symbol if it's from a custom maven repo?
I have a project where I'm using a dependency from a custom repository.我有一个项目,我在其中使用来自自定义存储库的依赖项。 This is what my build.gradle looks like (I have blurred out some dependencies for privacy):这就是我的 build.gradle 的样子(为了隐私,我已经模糊了一些依赖项):
plugins {
id 'org.springframework.boot' version '2.5.6'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'groovy'
}
group = 'com.myproject.projectx.sms'
sourceCompatibility = '11'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
maven {
url "s3://myproject-maven-repo"
authentication {
awsIm(AwsImAuthentication)
}
}
}
dependencies {
implementation 'org.postgresql:postgresql'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.security:spring-security-core'
implementation 'com.myproject.top:secret-project:1.2' <------------ Gradle won't download this. why?
testImplementation 'org.spockframework:spock-spring:2.0-groovy-3.0'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
exclude group: 'org.junit', module: 'junit'
}
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
}
test {
useJUnitPlatform()
}
There are red squiggly underlines when I hover over code that's using the top:secret-project
dependencies.当我将鼠标悬停在使用top:secret-project
依赖项的代码上时,会出现红色波浪形下划线。 This used to work in old projects, but why can't intellij recognize it in this project?这曾经在旧项目中有效,但为什么intellij在这个项目中无法识别它? Also I can run the project successfully in ubuntu terminal with gradle bootRun
.此外,我可以使用gradle bootRun
在 ubuntu 终端中成功运行该项目。 It's just intellij cannot recognize it.只是intellij无法识别它。 It also able to recognize spring, postgres, lombok & spock dependencies.它还能够识别 spring、postgres、lombok 和 spock 依赖项。
Cannot resolve symbol 'com.myproject.top.secret.TopSecretService'.
When click on build for gradle, I keep getting this error.当单击构建 gradle 时,我不断收到此错误。
Access Denied (Service: Amazon S3; Status Code: 403; Error Code: AccessDenied;)
I already exported the correct secret and keys in my .bashrc
file.我已经在我的.bashrc
文件中导出了正确的秘密和密钥。 I also already configured ~/.aws/credentials
.我也已经配置了~/.aws/credentials
。 But I'm still getting the error above.但我仍然收到上面的错误。
Am not really familiar with AwsImAuthentication nor the s3:// , but as it mentioned in the official doc that you need to add user/pass , or user/token as following我不太熟悉 AwsImAuthentication 和 s3:// ,但正如官方文档中提到的,您需要添加 user/pass 或 user/token 如下
maven {
url 'https://my_domain-111122223333.d.codeartifact.region.amazonaws.com/maven/my_repo/'
credentials {
username "aws"
password System.env.CODEARTIFACT_AUTH_TOKEN
}
}
where CODEARTIFACT_AUTH_TOKEN is enviroment variable to store your password/session .其中 CODEARTIFACT_AUTH_TOKEN 是用于存储您的密码/会话的环境变量。
You can also use the gradle.properties to retrive the value , just make sure to replace System.env.CODEARTIFACT_AUTH_TOKEN
with您还可以使用 gradle.properties 来检索值,只需确保将System.env.CODEARTIFACT_AUTH_TOKEN
替换为
project.findProperty.CODEARTIFACT_AUTH_TOKEN
where CODEARTIFACT_AUTH_TOKEN is store the password/token in your gradle properties . project.findProperty.CODEARTIFACT_AUTH_TOKEN
其中 CODEARTIFACT_AUTH_TOKEN 将密码/令牌存储在您的 gradle 属性中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.