Spring method present in code, but not present in JAR

时间:2018-08-22 13:53:17

标签: java spring spring-boot

I would like to invoke that method:

https://github.com/spring-projects/spring-boot/blob/2.0.x/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ErrorProperties.java#L73

But it's not available. It's not even present in decompiled code. But it should be, since JavaDoc says it's available from 1.3.0 version and it's public. My version is 2.0.0, I also checked 1.5.4. The link I gave is for 2.0.x and in GitHub it's still there. But in code it's not available, why?

POM:

<?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>test</groupId>
    <artifactId>test</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-autoconfigure</artifactId>
            <version>2.0.0.RELEASE</version>
        </dependency>
    </dependencies>


</project>

Code:

import org.springframework.boot.autoconfigure.web.ErrorProperties;

public class Test {

    ErrorProperties errorProperties = new ErrorProperties();

    public Test() {
        //Cannot resolve method getWhitelabel()
        errorProperties.getWhitelabel();
    }
}

1 个答案:

答案 0 :(得分:1)

该方法既不在2.0.0中,也不在2.0.3中,但在2.0.4(当前最新版本)中。

将您的pom.xml更改为:

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-autoconfigure</artifactId>
        <version>2.0.4.RELEASE</version>
    </dependency>
</dependencies>

它将编译。

相关问题