简体   繁体   English

Spring Boot 2项目可在IDE中工作,但不能在命令行中工作

[英]Spring Boot 2 project works in IDE but not command line

I am running a Spring Boot project. 我正在运行一个Spring Boot项目。 I can run the project from IntelliJ, however when I try and do mvn spring-boot:run I get java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException 我可以从IntelliJ运行项目,但是当我尝试执行mvn spring-boot:run我得到java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException

I have included 我已经包括

<dependency>
        <groupId>com.sun.xml.bind</groupId>
        <artifactId>jaxb-impl</artifactId>
        <version>2.3.0</version>
</dependency>

in my pom.xml file. 在我的pom.xml文件中。 I have even included java.xml.bind as an add modules in the pom. 我什至在pom中将java.xml.bind包含为添加模块。 But the issue still persists. 但是问题仍然存在。 What am I missing? 我想念什么?

Credit to @jny for the answer 归功于@jny的答案

I had the wrong dependency in the pom file. 我在pom文件中有错误的依赖性。 Replacing it with 替换为

<dependency>
   <groupId>javax.xml.bind</groupId> 
   <artifactId>jaxb-api</artifactId> 
   <version>2.3.0</version> 
</dependency>

corrected the issue. 更正了该问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Spring Boot的多个配置文件可在IDE中使用,但不能从命令行使用 - Spring Boot multiple profiles works in IDE but not from command line 在 Spring Boot Multimodule Mave 项目的命令行中指定 Spring 配置文件 - Specifying Spring profile on command line in Spring Boot Multimodule Mave project 我可以在没有 IDE 的情况下通过命令行编译和运行 spring mvc(不是 spring boot)吗? - Can I compile and run spring mvc (not spring boot) without IDE by command line? 从Maven或IDE运行Spring引导项目 - Run Spring boot project from Maven or IDE Java程序在IDE中运行,但不在命令行中运行 - Java program works from the IDE but not the command line spring.profiles.active不能从命令行使用,但可以在IDE中使用 - spring.profiles.active not being honored from command line, but works in IDE 由 maven 插件打包的 Spring 引导应用程序不起作用,在 IDE 中工作 - Spring boot application packaged by maven plugin not working, works in IDE spring boot 在命令行上运行时不读取 application.properties 文件,但在 STS 中工作 - spring boot does not read application.properties file when run on command line but works in STS 从带有mvn原型的命令行创建Spring Boot项目时出错:generate - Error when creating a Spring Boot project from command line with mvn archetype: generate Curl 命令不起作用(Spring Boot 项目) - Curl command not working (Spring Boot project)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM