Я прочитал все вопросы об ошибке maven «не удается найти символ», но думаю, они мне не подходят.
Прежде всего, я разработал образовательный проект с использованием Eclipse. Это простой чат, доступный на 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.
Если я очищаю и запускаю проект через 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>
Спасибо за любые идеи!