春季+ Gradle在Vscode中找不到类Path [它不是重复的,已经检查了类似的Path]
First of all, yes, I tried clean java language server workspace and all other answers present here:
请不要投票根据这个问题结束!
在尝试运行Spring Boot + Gradle应用程序时,它会出现以下错误:
无法自动解析模块paths/class路径,请在启动中指定值。
来源:Java的调试器(扩展)
是我的启动。JSON:
{
"configurations": [
{
"type": "java",
"name": "Spring Boot-SigprojApplication<sigproj-backend>",
"request": "launch",
"cwd": "${workspaceFolder}",
"mainClass": "com.sti.sigproj.SigprojApplication",
"projectName": "sigproj-backend",
"args": "",
"envFile": "${workspaceFolder}/.env"
}
]
}
这是我的.classpath:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="bin/test" path="src/test/java">
<attributes>
<attribute name="gradle_scope" value="test"/>
<attribute name="gradle_used_by_scope" value="test"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="bin/main" path="src/main/java">
<attributes>
<attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="bin/main" path="src/main/resources">
<attributes>
<attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin/default"/>
</classpath>
这是我的build.gradle.gradle:
/*
* This file was generated by the Gradle 'init' task.
*/
plugins {
id 'java'
id 'maven-publish'
id "org.springframework.boot" version "2.5.2"
id "io.spring.dependency-management" version "1.0.12.RELEASE"
}
jar {
manifest {
attributes(
'Main-Class': 'com.sti.sigproj.SigprojApplication'
)
}
}
repositories {
mavenLocal()
maven {
url = uri('https://repo.maven.apache.org/maven2/')
}
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa:2.5.2'
implementation 'org.springframework.boot:spring-boot-starter-validation:2.5.2'
implementation 'org.springframework.boot:spring-boot-starter-web:2.5.2'
implementation 'org.flywaydb:flyway-core:7.7.3'
implementation 'org.springframework.boot:spring-boot-starter-security:2.5.2'
implementation 'org.springframework.security.oauth:spring-security-oauth2:2.5.1.RELEASE'
implementation 'org.springframework.security.oauth.boot:spring-security-oauth2-autoconfigure:2.6.6'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client:2.5.2'
implementation 'org.modelmapper.extensions:modelmapper-spring:2.3.0'
implementation 'commons-codec:commons-codec:1.15'
implementation 'io.jsonwebtoken:jjwt:0.7.0'
implementation 'org.springframework.boot:spring-boot-starter-mail:2.5.2'
implementation 'io.springfox:springfox-swagger2:2.9.2'
implementation 'io.springfox:springfox-swagger-ui:2.9.2'
implementation('com.github.javafaker:javafaker:1.0.2') { exclude module: 'snakeyaml' }
runtimeOnly 'com.h2database:h2:1.4.200'
runtimeOnly 'org.springframework.boot:spring-boot-devtools:2.5.2'
runtimeOnly 'org.postgresql:postgresql:42.2.22'
testImplementation 'org.flywaydb.flyway-test-extensions:flyway-spring-test:5.0.0'
testImplementation 'org.springframework.boot:spring-boot-starter-test:2.5.2'
testImplementation 'org.springframework.security:spring-security-test:5.5.1'
testImplementation 'org.junit.vintage:junit-vintage-engine:5.7.2'
}
group = 'com.sti.sigproj'
version = '0.0.1-SNAPSHOT'
description = 'sigproj-backend'
java.sourceCompatibility = JavaVersion.VERSION_1_8
publishing {
publications {
maven(MavenPublication) {
from(components.java)
}
}
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
test {
useJUnitPlatform()
}
test.testLogging {
exceptionFormat 'full'
}
task stage(type: Copy, dependsOn: [clean, build]) {
from jar.archivePath
into project.rootDir
rename {
'app.jar'
}
}
stage.mustRunAfter(clean)
这是目录树和找到Sigprojapplication的地方:
src/
├── main
│ ├── docker
│ ├── java
│ │ └── com
│ │ └── sti
│ │ └── sigproj
│ │ ├── api
│ │ │ ├── controller
│ │ │ ├── exceptionhandler
│ │ │ └── generaldtos
│ │ ├── configs
│ │ │ └── security
│ │ ├── domain
│ │ │ ├── arquivos
│ │ │ ├── edital
│ │ │ ├── modalidade
│ │ │ ├── proposta
│ │ │ └── usuario
│ │ ├── SigprojApplication.java
│ │ └── support
│ │ ├── date
│ │ ├── faker
│ │ ├── json
│ │ ├── validations
│ │ └── verificacoes
│ └── resources
│ └── db
│ └── migration
└── test
└── java
└── com
└── sti
└── sigproj
├── api
│ └── controllers
└── support
└── tests
First of all, yes, I tried clean java language server workspace and all other answers present here: Java-VSCode error:Cannot resolve the modulepaths/classpaths automatically, please specify the value in the launch.json , it doesn't work!
DON'T VOTE TO CLOSE BASED ON THIS QUESTION, PLEASE!
In trying to run a spring boot + gradle application, but it gives the following error:
Cannot resolve the modulepaths/classpaths automatically, please specify the value in the launch.json.
Source: Debugger for Java (Extension)
Here is my launch.json:
{
"configurations": [
{
"type": "java",
"name": "Spring Boot-SigprojApplication<sigproj-backend>",
"request": "launch",
"cwd": "${workspaceFolder}",
"mainClass": "com.sti.sigproj.SigprojApplication",
"projectName": "sigproj-backend",
"args": "",
"envFile": "${workspaceFolder}/.env"
}
]
}
Here is my .classpath:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="bin/test" path="src/test/java">
<attributes>
<attribute name="gradle_scope" value="test"/>
<attribute name="gradle_used_by_scope" value="test"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="bin/main" path="src/main/java">
<attributes>
<attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="bin/main" path="src/main/resources">
<attributes>
<attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin/default"/>
</classpath>
Here is my build.gradle:
/*
* This file was generated by the Gradle 'init' task.
*/
plugins {
id 'java'
id 'maven-publish'
id "org.springframework.boot" version "2.5.2"
id "io.spring.dependency-management" version "1.0.12.RELEASE"
}
jar {
manifest {
attributes(
'Main-Class': 'com.sti.sigproj.SigprojApplication'
)
}
}
repositories {
mavenLocal()
maven {
url = uri('https://repo.maven.apache.org/maven2/')
}
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa:2.5.2'
implementation 'org.springframework.boot:spring-boot-starter-validation:2.5.2'
implementation 'org.springframework.boot:spring-boot-starter-web:2.5.2'
implementation 'org.flywaydb:flyway-core:7.7.3'
implementation 'org.springframework.boot:spring-boot-starter-security:2.5.2'
implementation 'org.springframework.security.oauth:spring-security-oauth2:2.5.1.RELEASE'
implementation 'org.springframework.security.oauth.boot:spring-security-oauth2-autoconfigure:2.6.6'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client:2.5.2'
implementation 'org.modelmapper.extensions:modelmapper-spring:2.3.0'
implementation 'commons-codec:commons-codec:1.15'
implementation 'io.jsonwebtoken:jjwt:0.7.0'
implementation 'org.springframework.boot:spring-boot-starter-mail:2.5.2'
implementation 'io.springfox:springfox-swagger2:2.9.2'
implementation 'io.springfox:springfox-swagger-ui:2.9.2'
implementation('com.github.javafaker:javafaker:1.0.2') { exclude module: 'snakeyaml' }
runtimeOnly 'com.h2database:h2:1.4.200'
runtimeOnly 'org.springframework.boot:spring-boot-devtools:2.5.2'
runtimeOnly 'org.postgresql:postgresql:42.2.22'
testImplementation 'org.flywaydb.flyway-test-extensions:flyway-spring-test:5.0.0'
testImplementation 'org.springframework.boot:spring-boot-starter-test:2.5.2'
testImplementation 'org.springframework.security:spring-security-test:5.5.1'
testImplementation 'org.junit.vintage:junit-vintage-engine:5.7.2'
}
group = 'com.sti.sigproj'
version = '0.0.1-SNAPSHOT'
description = 'sigproj-backend'
java.sourceCompatibility = JavaVersion.VERSION_1_8
publishing {
publications {
maven(MavenPublication) {
from(components.java)
}
}
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
test {
useJUnitPlatform()
}
test.testLogging {
exceptionFormat 'full'
}
task stage(type: Copy, dependsOn: [clean, build]) {
from jar.archivePath
into project.rootDir
rename {
'app.jar'
}
}
stage.mustRunAfter(clean)
Here is the tree of directories and the place where SigprojApplication is found:
src/
├── main
│ ├── docker
│ ├── java
│ │ └── com
│ │ └── sti
│ │ └── sigproj
│ │ ├── api
│ │ │ ├── controller
│ │ │ ├── exceptionhandler
│ │ │ └── generaldtos
│ │ ├── configs
│ │ │ └── security
│ │ ├── domain
│ │ │ ├── arquivos
│ │ │ ├── edital
│ │ │ ├── modalidade
│ │ │ ├── proposta
│ │ │ └── usuario
│ │ ├── SigprojApplication.java
│ │ └── support
│ │ ├── date
│ │ ├── faker
│ │ ├── json
│ │ ├── validations
│ │ └── verificacoes
│ └── resources
│ └── db
│ └── migration
└── test
└── java
└── com
└── sti
└── sigproj
├── api
│ └── controllers
└── support
└── tests
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
基于您的错误消息,请在您的
启动JSON
文件中添加以下配置:Based on your error message, please add the following configuration to your
launchjson
file: