清理后 Maven 不编译。 "cannot find symbol"

Maven does not compile after cleaning. "cannot find symbol"

我已经阅读了所有关于 "cannot find symbol" maven 错误的问题,但我想它们不适合我。

首先,我使用 Eclipse 开发了一个教育项目。这是一个简单的聊天,并且可以访问 on github。它可以编译并且 运行 很好,但是现在我需要在没有 Eclipse 而只有 Maven 的情况下编译它。我运行mvn clean,mvn validate(均成功)。然后 mvn compile 我得到错误:

C:\Users\fresh\Documents\git\SpringBootThymeleaf\SpringBootThymeleaf>mvn compile
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------< ru.aconsultant:SpringBootThymeleaf >-----------------
[INFO] Building SpringBootThymeleaf 0.0.1-SNAPSHOT
[INFO] --------------------------------[ war ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ SpringBootThymeleaf ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 22 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ SpringBootThymeleaf ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 21 source files to C:\Users\fresh\Documents\git\SpringBootThymeleaf\SpringBootThymeleaf\target\classes
[INFO] /C:/Users/fresh/Documents/git/SpringBootThymeleaf/SpringBootThymeleaf/src/main/java/ru/aconsultant/thymeleaf/controller/WebSocketConfiguration.java: C:\Users\fresh\Documents\git\SpringBootThymeleaf\SpringBootThymeleaf\src\main\java\ru\aconsultant\thymeleaf\controller\WebSocketConfiguration.java uses unchecked or unsafe operations.
[INFO] /C:/Users/fresh/Documents/git/SpringBootThymeleaf/SpringBootThymeleaf/src/main/java/ru/aconsultant/thymeleaf/controller/WebSocketConfiguration.java: Recompile with -Xlint:unchecked for details.
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/fresh/Documents/git/SpringBootThymeleaf/SpringBootThymeleaf/src/main/java/ru/aconsultant/thymeleaf/service/FileProcessor.java:[158,43] cannot find symbol
  symbol:   method readAllBytes()
  location: variable inputStream of type java.io.InputStream
[ERROR] /C:/Users/fresh/Documents/git/SpringBootThymeleaf/SpringBootThymeleaf/src/main/java/ru/aconsultant/thymeleaf/service/FileProcessor.java:[172,51] cannot find symbol
  symbol:   method readAllBytes()
  location: variable inputStream of type java.io.InputStream
[ERROR] /C:/Users/fresh/Documents/git/SpringBootThymeleaf/SpringBootThymeleaf/src/main/java/ru/aconsultant/thymeleaf/service/FileProcessor.java:[201,43] cannot find symbol
  symbol:   method readAllBytes()
  location: variable inputStream of type java.io.InputStream
[INFO] 3 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.669 s
[INFO] Finished at: 2020-06-17T10:48:00+03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project SpringBootThymeleaf: Compilation failure: Compilation failure:
[ERROR] /C:/Users/fresh/Documents/git/SpringBootThymeleaf/SpringBootThymeleaf/src/main/java/ru/aconsultant/thymeleaf/service/FileProcessor.java:[158,43] cannot find symbol
[ERROR]   symbol:   method readAllBytes()
[ERROR]   location: variable inputStream of type java.io.InputStream
[ERROR] /C:/Users/fresh/Documents/git/SpringBootThymeleaf/SpringBootThymeleaf/src/main/java/ru/aconsultant/thymeleaf/service/FileProcessor.java:[172,51] cannot find symbol
[ERROR]   symbol:   method readAllBytes()
[ERROR]   location: variable inputStream of type java.io.InputStream
[ERROR] /C:/Users/fresh/Documents/git/SpringBootThymeleaf/SpringBootThymeleaf/src/main/java/ru/aconsultant/thymeleaf/service/FileProcessor.java:[201,43] cannot find symbol
[ERROR]   symbol:   method readAllBytes()
[ERROR]   location: variable inputStream of type java.io.InputStream
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

此外,此后甚至 Eclipse 也无法 运行 正常投影。附加字符串出现在起始日志中:

2020-06-17 11:20:15.433  INFO 16244 --- [           main] .s.s.UserDetailsServiceAutoConfiguration : 

Using generated security password: fe0f803b-2116-43b6-910c-47e5b11b168b

并且出现了一些默认的 spring 安全登录页面,而不是我的自定义页面。当我在 Eclipse 中创建 "Project -> Clean" 时,这些问题就消失了。

如果我通过 Eclipse 清理和 运行 项目,而不是用 maven 编译它(没有 mvn clean),它也是成功的。

我完全意识到依赖项或导入有问题,但我无法找出具体问题。我什至用相同的 POM 创建了一个新项目——maven 成功编译了它。我在下面提供我的 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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.7.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>ru.aconsultant</groupId>
    <artifactId>SpringBootThymeleaf</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <name>SpringBootThymeleaf</name>
    <description>Spring Boot and Thymeleaf</description>

    <properties>
        <java.version>1.8</java.version>
        <spring-security.version>5.3.2.RELEASE</spring-security.version>
        <spring.version>5.0.6.RELEASE</spring.version>
    </properties>

    <dependencies>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</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-websocket</artifactId>
        </dependency>

        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>webjars-locator</artifactId>
            <version>0.36</version>
        </dependency>

        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>sockjs-client</artifactId>
            <version>1.0.2</version>
        </dependency>

        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>stomp-websocket</artifactId>
            <version>2.3.3</version>
        </dependency>

        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>bootstrap</artifactId>
            <version>3.3.7</version>
        </dependency>

        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>jquery</artifactId>
            <version>3.1.0</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>com.zaxxer</groupId>
                    <artifactId>HikariCP</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-jdbc</artifactId>
        </dependency>

        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-core</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-web</artifactId>
        </dependency>

        <dependency>
            <groupId>net.sourceforge.jtds</groupId>
            <artifactId>jtds</artifactId>
            <scope>runtime</scope>
        </dependency> 

        <!-- #refactor --> 
        <dependency>
            <groupId>org.springframework.session</groupId>
            <artifactId>spring-session-core</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.session</groupId>
            <artifactId>spring-session-jdbc</artifactId>
        </dependency>

        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20190722</version>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>2.11.0</version>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
        </dependency>

        <dependency>
            <groupId>javax.servlet.jsp.jstl</groupId>
            <artifactId>jstl-api</artifactId>
            <version>1.2</version>
        </dependency>   

        <!-- file processing -->
        <dependency>
            <groupId>commons-net</groupId>
            <artifactId>commons-net</artifactId>
            <version>3.6</version>
        </dependency>

        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>1.3.2</version>
        </dependency>

    </dependencies>

    <build>
        <plugins>

            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>

            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-surefire-plugin</artifactId>
            </plugin>

        </plugins>
    </build>

</project>

感谢您的任何想法!

问题出在 java 版本中。支持方法 readAllBytes() 。我没有提到它,因为我的 POM 中有 java 1.8 版,但 Eclipse 在其安装的库中有 jdk 14 并以某种方式使用它进行编译。