Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 运行jar的反应与在Intellij中运行不同_Java_Spring Boot_Intellij Idea_Cmd_Jira Rest Api - Fatal编程技术网

Java 运行jar的反应与在Intellij中运行不同

Java 运行jar的反应与在Intellij中运行不同,java,spring-boot,intellij-idea,cmd,jira-rest-api,Java,Spring Boot,Intellij Idea,Cmd,Jira Rest Api,我正在使用maven在SpringBoot中进行一个项目。 首先让我告诉你,在intellij中,一切都运行得很好,我可以打开网站,但是: 现在我必须创建一个测试环境,所以我使用maven生成了一个Jar。 我选择了正确的spring概要文件,现在我正在命令行中使用以下命令运行jar: java -jar .\pegusapps-dashboard-0.4.0-SNAPSHOT.jar --spring.profiles.active=ext-api-dev,dev 当我运行这个程序时,Spr

我正在使用maven在SpringBoot中进行一个项目。 首先让我告诉你,在intellij中,一切都运行得很好,我可以打开网站,但是: 现在我必须创建一个测试环境,所以我使用maven生成了一个Jar。 我选择了正确的spring概要文件,现在我正在命令行中使用以下命令运行jar:

java -jar .\pegusapps-dashboard-0.4.0-SNAPSHOT.jar --spring.profiles.active=ext-api-dev,dev
当我运行这个程序时,SpringBoot启动并开始做intellij中的正常工作,但是当他们编译我们使用RESTAPI的部分时。它给了我这个错误:

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)

  • 我们使用一个接口来完成对RESTAPI的所有调用
  • 然后我们有一个api服务层的接口
  • 然后我们有了服务实现,他们在其中访问执行所有api调用的接口
在服务的实现内部,我们自动连接构造函数中的第一个接口,这就是错误的来源(来自cmd窗口)


提前谢谢

您可能想尝试使用ApacheMaven Shade插件构建JAR,如下所示

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <configuration>
                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                        <mainClass>fully.qualified.MainClass</mainClass>
                    </manifest>
                </archive>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
            </configuration>
        </plugin>
    </plugins>
</build>

org.apache.maven.plugins
maven jar插件
真的
完全合格
maven汇编插件
带有依赖项的jar

如果您尚未使用,请使用以下命令

<build>
 <plugins>
  <plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <version>2.0.0.RELEASE</version>
    <executions>
     <execution>
      <goals>
       <goal>repackage</goal>
      </goals>
     </execution>
    </executions>
  </plugin>
</plugins>
</build>

org.springframework.boot
springbootmaven插件
2.0.0.1版本
重新包装

您是否检查了intellij idea在运行jar时执行的命令?它应该位于控制台输出的顶部。@krizajb它运行一个非常长的命令,我能从中得到的是,它将所有依赖项添加到命令行中。看起来您不是在用spring boot maven插件创建jar。这个插件创建了一个包含所有依赖项的胖罐子。@酷,这确实是答案,我在网上找到了这个,现在将尝试一下。