简体   繁体   中英

Maven excludes the configuration processor package from the WAR

After upgrading spring-boot version from 2.1.8.RELEASE to 2.5.6 , the spring-boot-configuration-processor package was upgraded to. When running the WAR we get the exception below that it cannot find the class and indeed the WAR does not contain the JAR (spring-boot-configuration-processor) for this package.

As workaround we have downgraded this package to 2.3.12.RELEASE which works on runtime. We have tried with versions 2.3.6 / 2.4.14 / 2.4.7 / 2.4.0 but the jar is not included in the WAR.

As I understood, the package is used by the IDE, so my question is: Why It is need in runtime? Should it be included in my WAR? How does Maven decide to exclude a package from the WAR?

Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name appointmentRepository defined in com.project.project.repositories.AppointmentRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Cannot create inner bean (inner bean)#37291159 of type [org.springframework.orm.jpa.SharedEntityManagerCreator] while setting bean property entityManager; 
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name (inner bean)#37291159: Cannot resolve reference to bean entityManagerFactory while setting constructor argument; 
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name entityManagerFactory defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org.springframework.boot.configurationprocessor.json.JSONException

application.properties:

com.project.file.maximumSize=5242880
com.project.file.contentTypes=application/pdf,image/png,image/jpeg
com.project.file.extensions=pdf,png,jpeg,jpg
com.project.file.maxFilesPerAttachmentType=5

additional-spring-configuration-metadata.json

{"properties": [
  {
    "name": "com.project.file.maximum-size",
    "type": "java.lang.Long",
    "description": "Sets the maximum valid size, in Bytes, for the uploaded attachments."
  },
  {
    "name": "com.project.file.content-types",
    "type": "java.util.List<java.lang.String>",
    "description": "A list of the authorized content types for the uploaded attachments."
  },
  {
    "name": "com.project.file.extensions",
    "type": "java.util.List<java.lang.String>",
    "description": "A list of the authorized extensions."
  }
]}

The oldest version of springframework.boot.configurationprocessor before xxxRELEASE was on default scope compile that's why it was included in WEB-INF\lib, and did not cause classnotFoundException. I upgraded the version of the configurationprocessor package and changed my JSONObject and JSONException imports to json.org.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM