Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

多模块项目classpath问题 #176

Closed
JavaHello opened this issue Apr 25, 2018 · 4 comments · Fixed by #239
Closed

多模块项目classpath问题 #176

JavaHello opened this issue Apr 25, 2018 · 4 comments · Fixed by #239
Assignees
Labels
Milestone

Comments

@JavaHello
Copy link

在工作空间有多个项目时(A,B),运行A项目的test case,classpath中有B项目的目录,A并没有依赖于B,使用maven运行test case是正常的

@ansyral
Copy link
Collaborator

ansyral commented Apr 25, 2018

@JavaHello could you help share more details about the error message or stack trace? The test case cannot run successfully because class path contains the bin directory of project B and it couldn't be resolved?

@JavaHello
Copy link
Author

JavaHello commented Apr 25, 2018

我的是spring boot项目,A项目加载了B项目的配置文件导致无法启动。

下面是日志是运行demo-a-api的日志,读取的配置文件却是demo-b-api的

2018-04-25 19:05:25.631 [main] DEBUG o.s.b.l.ClasspathLoggingApplicationListener - Application started with classpath: [file:/home/hy/.config/Code/User/workspaceStorage/ba2cf95c797f088fa9dda0a92a06956c/vscjava.vscode-java-test/1524654324177/path.jar]

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.5.7.RELEASE)

2018-04-25 19:05:25.770 [main] INFO  c.s.y.w.c.b.ActiveCodeControllerTest - Starting ActiveCodeControllerTest on hy-OptiPlex-3020 with PID 12191 (started by hy in /home/hy/workspace-vscode/java)
2018-04-25 19:05:25.777 [main] INFO  c.s.y.w.c.b.ActiveCodeControllerTest - The following profiles are active: dev
2018-04-25 19:05:25.777 [main] DEBUG o.s.boot.SpringApplication - Loading source class com.shouyinjia.yangka.ApiApplication
2018-04-25 19:05:26.115 [background-preinit] INFO  o.h.validator.internal.util.Version - HV000001: Hibernate Validator 5.3.5.Final
2018-04-25 19:05:26.268 [main] DEBUG o.s.b.c.c.ConfigFileApplicationListener - Activated profiles dev
2018-04-25 19:05:26.269 [main] DEBUG o.s.b.c.c.ConfigFileApplicationListener - Loaded config file 'file:/home/hy/workspace-vscode/java/demo-b-api/target/classes/application.yml' (classpath:/application.yml)
2018-04-25 19:05:26.271 [main] DEBUG o.s.b.c.c.ConfigFileApplicationListener - Loaded config file 'file:/home/hy/workspace-vscode/java/demo-b-api/target/classes/application-dev.yml' (classpath:/application-dev.yml)
2018-04-25 19:05:26.273 [main] DEBUG o.s.b.c.c.ConfigFileApplicationListener - Skipped (empty) config file 'file:/home/hy/workspace-vscode/java/demo-b-api/target/classes/application-dev.yml' (classpath:/application-dev.yml) for profile dev
2018-04-25 19:05:26.275 [main] DEBUG o.s.b.c.c.ConfigFileApplicationListener - Skipped (empty) config file 'file:/home/hy/workspace-vscode/java/demo-b-api/target/classes/application.yml' (classpath:/application.yml) for profile dev
2018-04-25 19:05:26.276 [main] INFO  o.s.w.c.s.GenericWebApplicationContext - Refreshing org.springframework.web.context.support.GenericWebApplicationContext@561868a0: startup date [Wed Apr 25 19:05:26 CST 2018]; root of context hierarchy

@ansyral
Copy link
Collaborator

ansyral commented Apr 27, 2018

thanks for the info, @JavaHello . Seems class path isn't well resolved when a workspace contains multiple projects. Right now, you can workaround it by multiroot workspace, namely

  1. opening the folder that contains projectA
  2. file -> add folder to workspace->choose the folder that contains projectB
  3. save workspace.

@ansyral ansyral added the bug label Apr 27, 2018
@ansyral ansyral self-assigned this Apr 27, 2018
@JavaHello
Copy link
Author

@ansyral 谢谢你的解答,这样可以使他们正常运行

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants