【发布时间】:2018-08-25 09:41:29
【问题描述】:
我正在使用 maven 在 Spring Boot 中开发一个项目。 首先让我告诉你,在 intellij 中,一切运行良好,我可以打开网站,但是: 现在我要创建一个测试环境,所以我使用maven生成了一个Jar。 我已经选择了正确的弹簧配置文件,现在我正在命令行中使用此命令运行 jar:
java -jar .\pegusapps-dashboard-0.4.0-SNAPSHOT.jar --spring.profiles.active=ext-api-dev,dev
当我运行它时,spring boot 会启动并开始执行 intellij 中的正常工作,但是当他们编译我们使用 rest api 的部分时。它给了我这个错误:
Description:
Parameter 0 of constructor in com.pegusapps.dashboard.integration.tempo.TempoServiceImpl required a bean of type 'com.pegusapps.dashboard.integration.tempo.TempoRestApi' that could not be found.
Action:
Consider defining a bean of type 'com.pegusapps.dashboard.integration.tempo.TempoRestApi' in your configuration.
让我解释一下api的结构。 (这是一个jira rest api)
- 我们使用一个接口来执行对其余 api 的所有调用。
- 那么我们就有了api服务层的接口。
- 然后我们有了服务实现,他们可以在其中访问对 api 进行所有调用的接口。
在服务的实现内部,我们自动装配构造函数中的第一个接口,这就是错误的来源(来自 cmd 窗口)。
提前致谢!
【问题讨论】:
-
你检查过intellij-idea在运行jar时执行了什么命令吗?它应该在控制台输出的顶部。
-
@krizajb 它运行了一个非常长的命令,而我可以从中得到的,是将所有依赖项添加到命令行。
-
看起来您没有使用 spring-boot-maven-plugin 创建 jar。该插件创建了一个包含所有依赖项的胖 jar。
-
@cool 这确实是答案,我在网上找到了这个,现在将尝试。
标签: java spring-boot intellij-idea cmd jira-rest-api