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

时间:2018-10-26 10:05:08

标签: java spring maven spring-boot bazel

我正在将Spring Boot应用程序从Maven迁移到bazel。我在工作空间中将pom.xml中的所有依赖项都列为maven_jar()。我收到一个错误消息,说org.springframework.boot.web.support软件包不存在。它属于我已经包含的org.springframework.boot jar。我该怎么做才能解决此问题?

我的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>

    <groupId>com.example.abc</groupId>
    <artifactId>abcclient</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>

    <name>abcclient</name>
    <description>ABC Client</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.2.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <finalName>ROOT</finalName>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.maven.shared</groupId>
                        <artifactId>maven-filtering</artifactId>
                        <version>1.3</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>
</project>

还有我的工作场所工作空间

maven_jar(
    name = "org_springframework_boot_spring_boot",
    artifact = "org.springframework.boot:spring-boot:jar:1.2.3.RELEASE"
)

maven_jar(
    name = "org_springframework_boot_spring_boot_autoconfigure",
    artifact = "org.springframework.boot:spring-boot-autoconfigure:jar:2.0.6.RELEASE"
)

maven_jar(
    name = "org_springframework_spring_context",
    artifact = "org.springframework:spring-context:jar:5.1.1.RELEASE"
)

maven_jar(
    name = "org_springframework_boot_spring_boot_starter_aop",
    artifact = "org.springframework.boot:spring-boot-starter-aop:jar:2.0.6.RELEASE"
)

maven_jar(
    name = "org_springframework_boot_spring_boot_starter_web",
    artifact = "org.springframework.boot:spring-boot-starter-web:jar:2.0.6.RELEASE"
)

maven_jar(
    name = "org_springframework_boot_spring_boot_starter_test",
    artifact = "org.springframework.boot:spring-boot-starter-test:jar:2.0.6.RELEASE"
)

maven_jar(
    name = "org_apache_tomcat_embed_tomcat_embed_jasper",
    artifact = "org.apache.tomcat.embed:tomcat-embed-jasper:jar:9.0.12"
)

maven_jar(
    name = "javax_servlet_jstl",
    artifact = "javax.servlet:jstl:jar:1.2"
)

最后是我的构建文件

java_binary(
    name = "ABCClient",
    srcs = glob(["src/main/java/com/example/abc/*.java"]),
    deps = [
        "@org_springframework_boot_spring_boot//jar",
        "@org_springframework_boot_spring_boot_autoconfigure//jar",
        "@org_springframework_spring_context//jar",
        "@org_springframework_boot_spring_boot_starter_aop//jar",
        "@org_springframework_boot_spring_boot_starter_web//jar",
        "@org_apache_tomcat_embed_tomcat_embed_jasper//jar",
        "@javax_servlet_jstl//jar"
    ]
)

1 个答案:

答案 0 :(得分:2)

您要更改Spring Boot版本,因此必须更改所有support导入:

Spring Boot 1.5

import org.springframework.boot.web.support

Spring Boot 2.0

import org.springframework.boot.web.servlet.support

这是因为基于Servlet的Web服务器的支持类已移至new package