Spring应用程序启动异常

6ovsh4lw  于 2024-01-05  发布在  Spring
关注(0)|答案(1)|浏览(299)

我试图使用jar文件运行我的应用程序。当我在ide中运行它时,它工作得很好,当我试图在java -jar myApp.jar这样的终端中执行它时,就会出现此错误

  1. Exception in thread "main" java.lang.AbstractMethodError: Receiver class org.springframework.boot.logging.logback.RootLogLevelConfigurator does not define or inherit an implementation of the resolved method 'abstract void configure(ch.qos.logback.classic.LoggerContext)' of interface ch.qos.logback.classic.spi.Configurator.
  2. at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:156)
  3. at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:84)
  4. at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:55)
  5. at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150)
  6. at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124)
  7. at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:412)
  8. at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:357)
  9. at org.apache.commons.logging.LogAdapter$Slf4jAdapter.createLocationAwareLog(LogAdapter.java:121)
  10. at org.apache.commons.logging.LogAdapter.createLog(LogAdapter.java:95)
  11. at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:67)
  12. at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:59)
  13. at org.springframework.boot.SpringApplication.<clinit>(SpringApplication.java:186)
  14. at su.ezhidze.server.ServerApplication.main(ServerApplication.java:10)

字符串
所以我做了什么,我创建了一个jar文件,就像这样:


的数据
然后试图运行它,但这发生了



这是我的pom文件,它是有点乱,但它的工作正常,当我运行的应用程序的想法

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  4. <modelVersion>4.0.0</modelVersion>
  5. <parent>
  6. <groupId>org.springframework.boot</groupId>
  7. <artifactId>spring-boot-starter-parent</artifactId>
  8. <version>3.1.5</version>
  9. <relativePath/> <!-- lookup parent from repository -->
  10. </parent>
  11. <groupId>su.ezhidze</groupId>
  12. <artifactId>server</artifactId>
  13. <version>0.0.1-SNAPSHOT</version>
  14. <name>server</name>
  15. <description>Medicine app server</description>
  16. <properties>
  17. <java.version>21</java.version>
  18. </properties>
  19. <dependencies>
  20. <dependency>
  21. <groupId>org.springframework.boot</groupId>
  22. <artifactId>spring-boot-starter-data-jpa</artifactId>
  23. </dependency>
  24. <dependency>
  25. <groupId>org.springframework.boot</groupId>
  26. <artifactId>spring-boot-starter-web</artifactId>
  27. </dependency>
  28. <dependency>
  29. <groupId>org.springframework.boot</groupId>
  30. <artifactId>spring-boot-starter-log4j2</artifactId>
  31. </dependency>
  32. <dependency>
  33. <groupId>org.springframework.boot</groupId>
  34. <artifactId>spring-boot-starter-websocket</artifactId>
  35. </dependency>
  36. <dependency>
  37. <groupId>jakarta.validation</groupId>
  38. <artifactId>jakarta.validation-api</artifactId>
  39. <version>3.0.2</version>
  40. </dependency>
  41. <dependency>
  42. <groupId>com.mysql</groupId>
  43. <artifactId>mysql-connector-j</artifactId>
  44. <scope>runtime</scope>
  45. </dependency>
  46. <dependency>
  47. <groupId>org.projectlombok</groupId>
  48. <artifactId>lombok</artifactId>
  49. <optional>true</optional>
  50. </dependency>
  51. <dependency>
  52. <groupId>org.springframework.boot</groupId>
  53. <artifactId>spring-boot-starter-test</artifactId>
  54. <scope>test</scope>
  55. </dependency>
  56. <dependency>
  57. <groupId>org.springframework.security</groupId>
  58. <artifactId>spring-security-crypto</artifactId>
  59. <version>6.1.5</version>
  60. </dependency>
  61. <dependency>
  62. <groupId>org.springframework.boot</groupId>
  63. <artifactId>spring-boot-starter-validation</artifactId>
  64. </dependency>
  65. <dependency>
  66. <groupId>org.springframework.boot</groupId>
  67. <artifactId>spring-boot-starter-security</artifactId>
  68. </dependency>
  69. <dependency>
  70. <groupId>io.jsonwebtoken</groupId>
  71. <artifactId>jjwt</artifactId>
  72. <version>0.9.1</version>
  73. </dependency>
  74. <dependency>
  75. <groupId>javax.xml.bind</groupId>
  76. <artifactId>jaxb-api</artifactId>
  77. <version>2.3.0</version>
  78. </dependency>
  79. </dependencies>
  80. <build>
  81. <plugins>
  82. <plugin>
  83. <groupId>org.springframework.boot</groupId>
  84. <artifactId>spring-boot-maven-plugin</artifactId>
  85. <configuration>
  86. <image>
  87. <builder>paketobuildpacks/builder-jammy-base:latest</builder>
  88. </image>
  89. <excludes>
  90. <exclude>
  91. <groupId>org.projectlombok</groupId>
  92. <artifactId>lombok</artifactId>
  93. </exclude>
  94. </excludes>
  95. </configuration>
  96. </plugin>
  97. </plugins>
  98. </build>
  99. </project>


我自己尝试添加一些与logback相关的依赖项,但没有帮助

jgzswidk

jgzswidk1#

我不知道这个错误的具体原因是什么,但我能够找到一个解决方案:我在不使用ide的情况下构建了jar文件,我安装了maven,并在终端中打开了pom.xml文件夹,并使用mvn package命令构建了jar文件。然后jar文件运行正常,没有任何错误。

相关问题