org.springframework.boot.web.support does not exist

前端 未结 4 1352
一向
一向 2021-02-12 09:48

I\'m changing build systems from maven to gradle for a spring boot project. I get this stacktrace

19:03:08: Executing external task \'bootRun\'...
/home/dac/proj         


        
相关标签:
4条回答
  • 2021-02-12 10:12

    It's probably an import issue in your source code - your Gradle build script uses Spring Boot 1.3.6.RELEASE in which SpringBootServletInitializer has the following fully qualified name:

    org.springframework.boot.context.web.SpringBootServletInitializer 
    

    Your Maven pom.xml, however, uses Spring Boot 1.4.0.BUILD-SNAPSHOT, in which the package name was changed to:

    org.springframework.boot.web.support.SpringBootServletInitializer
    

    So if you go to your SampleJettyJspApplication and change the import to

    import org.springframework.boot.context.web.SpringBootServletInitializer;
    

    everything should be fine.

    Alternatively, you could alter your Gradle build script to import 1.4.0.BUILD-SNAPSHOT, but that would require adding Spring's snapshot repository:

    buildscript {
        repositories {
            maven.url "http://repo.spring.io/snapshot"
            mavenCentral()
        }
    
        dependencies {
            classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.0.BUILD-SNAPSHOT")
        }
    }
    
    0 讨论(0)
  • 2021-02-12 10:16
    org.springframework.boot.web.support.SpringBootServletInitializer 
    

    is deprecated.

    use below instead:

    org.springframework.boot.web.servlet.support.SpringBootServletInitializer
    
    0 讨论(0)
  • 2021-02-12 10:17

    You should use the same spring boot version 1.4.0.BUILD-SNAPSHOT as in maven. org.springframework.boot.web.support.SpringBootServletInitializer was introduced since 1.4.0 that's why gradle cannot find it.

    0 讨论(0)
  • 2021-02-12 10:27

    You are using org.springframework.boot.context.web.SpringBootServletInitializer this is deprecated. Instead:

    Use

    org.springframework.boot.web.support.SpringBootServletInitializer

    For SpringBoot 2.0

    org.springframework.boot.web.servlet.support.SpringBootServletInitializer

    0 讨论(0)
提交回复
热议问题