I've read all questions about "cannot find symbol" maven error, but I guess they are not appropriate for me.
First of all, I developed an educational project using Eclipse. It's a simple chat and it's accessible on github. It compiles and runs fine, but now I need to compile it with no Eclipse but Maven. I run mvn clean
, mvn validate
(both successful). Then mvn compile
and I get errors:
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
Moreover, after that even Eclipse could not run project properly. Additional string appears in the starting log:
2020-06-17 11:20:15.433 INFO 16244 --- [ main] .s.s.UserDetailsServiceAutoConfiguration :
Using generated security password: fe0f803b-2116-43b6-910c-47e5b11b168b
And some default spring security login page appears instead of my custom one. These issues are gone as I make "Project -> Clean" in Eclipse.
If I clean and run project via Eclipse, than compile it with maven (with no mvn clean
), it's also successful.
I completely realize that there's something bad with dependencies or imports, but I can't find out what exactly. I even created a new project with the same POM - maven compiled it successfully. I provide my POM below:
<?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>
Thank you for any ideas!