org.springframework.boot.web.support不存在

尼古拉斯:

我改变了从Maven构建系统摇篮的弹簧引导工程。我得到这个堆栈跟踪

19:03:08: Executing external task 'bootRun'...
/home/dac/proj/spring-boot-master/spring-boot-samples/spring-boot-sample-jetty-jsp/src/main/java/sample/jetty/jsp/SampleJettyJspApplication.java:22: error: package org.springframework.boot.web.support does not exist
import org.springframework.boot.web.support.SpringBootServletInitializer;
                                           ^
/home/dac/proj/spring-boot-master/spring-boot-samples/spring-boot-sample-jetty-jsp/src/main/java/sample/jetty/jsp/SampleJettyJspApplication.java:25: error: cannot find symbol
public class SampleJettyJspApplication extends SpringBootServletInitializer {
                                               ^
  symbol: class SpringBootServletInitializer
/home/dac/proj/spring-boot-master/spring-boot-samples/spring-boot-sample-jetty-jsp/src/main/java/sample/jetty/jsp/SampleJettyJspApplication.java:27: error: method does not override or implement a method from a supertype
    @Override
    ^
3 errors
:compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 2.334 secs
Compilation failed; see the compiler error output for details.
19:03:10: External task execution finished 'bootRun'.

我的 build.gradle

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath "org.springframework.boot:spring-boot-gradle-plugin:1.3.6.RELEASE"
        classpath 'org.springframework:springloaded:1.2.5.RELEASE'
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'
apply plugin: 'rebel'

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath group: 'org.zeroturnaround', name: 'gradle-jrebel-plugin', version: '1.1.3'
    }
}
jar {
    baseName = 'gs-spring-boot'
    version =  '0.1.0'
}

repositories {
    mavenCentral()
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
    // tag::jetty[]
    compile("org.springframework.boot:spring-boot-starter-web") {
        exclude module: "spring-boot-starter-tomcat"
    }
    compile("org.springframework.boot:spring-boot-starter-jetty")
    // end::jetty[]
    // tag::actuator[]
    compile("org.springframework.boot:spring-boot-starter-actuator")

    testCompile("org.springframework.boot:spring-boot-starter-test")
    testCompile("junit:junit")

}

// change default IntelliJ output directory for compiling classes
idea {
    module {
        inheritOutputDirs = false
        outputDir = file("$buildDir/classes/main/")
    }
}

task wrapper(type: Wrapper) {
    gradleVersion = '2.3'
}

我的 pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <!-- Your own application should inherit from spring-boot-starter-parent -->
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-samples</artifactId>
        <version>1.4.0.BUILD-SNAPSHOT</version>
    </parent>
    <artifactId>spring-boot-sample-jetty-jsp</artifactId>
    <packaging>war</packaging>
    <name>Spring Boot Jetty JSP Sample</name>
    <description>Spring Boot Jetty JSP Sample</description>
    <url>http://projects.spring.io/spring-boot/</url>
    <organization>
        <name>Pivotal Software, Inc.</name>
        <url>http://www.spring.io</url>
    </organization>
    <properties>
        <main.basedir>${basedir}/../..</main.basedir>
        <m2eclipse.wtp.contextRoot>/</m2eclipse.wtp.contextRoot>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-validation</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.tomcat.embed</groupId>
                    <artifactId>tomcat-embed-el</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jetty</artifactId>
            <!--<scope>provided</scope>-->
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>apache-jsp</artifactId>
            <!--<scope>provided</scope>-->
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <executable>true</executable>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <useSystemClassLoader>false</useSystemClassLoader>
                </configuration>
            </plugin>



        </plugins>
    </build>
</project>

我应该如何提供给摇篮包?

米洛斯·米利沃赫维奇:

这也可能是在源代码中导入的问题 - 你的摇篮构建脚本使用了Spring启动1.3.6.RELEASE其中SpringBootServletInitializer具有以下完全合格的名称:

org.springframework.boot.context.web.SpringBootServletInitializer 

你的Maven pom.xml的,但是,使用了Spring启动1.4.0.BUILD-快照,其中包更名为:

org.springframework.boot.web.support.SpringBootServletInitializer

所以,如果你去你SampleJettyJspApplication,改变进口

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

一切都应该罚款。

或者,你可以改变你的摇篮构建脚本来进口1.4.0.BUILD-快照,但这需要增加Spring的快照库:

buildscript {
    repositories {
        maven.url "http://repo.spring.io/snapshot"
        mavenCentral()
    }

    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.0.BUILD-SNAPSHOT")
    }
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

org.springframework.boot.web.support.does 不存在

[org.springframework.web.multipart.support.MissingServletRequestPartException:所需的请求部分“文件”不存在

包org.springframework.boot不存在

类路径资源[org / springframework / boot / autoconfigure / web / ServerPropertiesAutoConfiguration.class]无法打开,因为它不存在

错误:java:软件包org.springframework.boot不存在

导入到IntelliJ-错误包org.springframework.boot不存在

JasperReportsPdfView:包org.springframework.web.servlet.view.jasperreports不存在

org.springframework.web.bind.MissingServletRequestParameterException:必需的长参数'userId'不存在”

异常:org.springframework.web.bind.MissingServletRequestParameterException:所需的字符串参数“ params”不存在

org.springframework.web.bind.ServletRequestBindingException类'binderId'不存在

为什么org.springframework.boot不能导入,而org.springframework.web可以导入?

导入org.springframework.boot.autoconfigure.web.ErrorAttributes无法解析

IntelliJ-包org.springframework.stereotype不存在

找不到类org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer

org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver handleHttpRequestMethodNotSupported

Spring Boot构建包org.junit不存在

Spring Boot org.springframework.web.util.NestedServletException:请求处理失败

Spring Boot 1.5.3 NoSuchMethodError:org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.getResponseStatus()

org.springframework.boot.web.embedded.tomcat.ConnectorStartFailedException上IDEA终极2019.3

是否已将类'org.springframework.boot.autoconfigure.web.HttpMapperProperties'标记为已弃用?

NoSuchBeanDefinitionException:没有可用的'org.springframework.boot.web.reactive.error.ErrorAttributes'类型的合格bean:

SpringBoot 2.0.0.RELEASE中的org.springframework.boot.autoconfigure.web.ErrorAttributes

软件包org.springframework.cloud.netflix.zuul不存在

org.springframework.security.authentication.encoding在maven中不存在

@ComponentScan在org.springframework.context.annotation包中不存在

org.springframework.jdbc.support.MetaDataAccessException:Spring Boot中的JDBC DatabaseMetaData方法

升级到Spring Boot 2.2.0会引发ClassNotFoundException::org.springframework.integration.handler.support.HandlerMethodArgumentResolversHolder

错误[org.springframework.web.servlet.DispatcherServlet]

org.springframework.web.servlet.DispatcherServlet noHandlerFound