I am using Maven Buildin Eclipse IDE for a Spring project for uploading files.SPRING. The error is arising from
1-Plugin. I deleted the maven-compiler plugin from /.m2 directory (Windows), but the error still exist. The usual consensus is to delete whole ./m2 directory which is not feasible as I have other projects.
2- The FileUploadTest.java seems to be giving out a lot of errors. Is this due to corrupted jars or error in my pom.xml file?
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 34.910 s
[INFO] Finished at: 2018-06-14T11:03:01+05:30
[INFO] Final Memory: 32M/297M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project SpringMVCImage: Compilation failure: Compilation failure:
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[6,20] package org.hamcrest does not exist
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[7,17] package org.junit does not exist
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[8,24] package org.junit.runner does not exist
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[11,63] package org.springframework.boot.test.autoconfigure.web.servlet does not exist
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[12,45] package org.springframework.boot.test.context does not exist
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[13,50] package org.springframework.boot.test.mock.mockito does not exist
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[14,36] package org.springframework.mock.web does not exist
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[15,47] package org.springframework.test.context.junit4 does not exist
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[16,44] package org.springframework.test.web.servlet does not exist
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[18,26] package org.mockito does not exist
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[18,1] static import only from classes and interfaces
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[19,26] package org.mockito does not exist
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[19,1] static import only from classes and interfaces
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[20,59] package org.springframework.test.web.servlet.request does not exist
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[20,1] static import only from classes and interfaces
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[21,59] package org.springframework.test.web.servlet.request does not exist
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[21,1] static import only from classes and interfaces
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[22,58] package org.springframework.test.web.servlet.result does not exist
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[22,1] static import only from classes and interfaces
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[23,58] package org.springframework.test.web.servlet.result does not exist
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[23,1] static import only from classes and interfaces
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[24,58] package org.springframework.test.web.servlet.result does not exist
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[24,1] static import only from classes and interfaces
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[29,2] cannot find symbol
[ERROR] symbol: class RunWith
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[30,2] cannot find symbol
[ERROR] symbol: class AutoConfigureMockMvc
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[31,2] cannot find symbol
[ERROR] symbol: class SpringBootTest
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[35,13] cannot find symbol
[ERROR] symbol: class MockMvc
[ERROR] location: class com.ayman.image.FileUploadTests
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[37,6] cannot find symbol
[ERROR] symbol: class MockBean
[ERROR] location: class com.ayman.image.FileUploadTests
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[40,6] cannot find symbol
[ERROR] symbol: class Test
[ERROR] location: class com.ayman.image.FileUploadTests
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[51,6] cannot find symbol
[ERROR] symbol: class Test
[ERROR] location: class com.ayman.image.FileUploadTests
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[63,6] cannot find symbol
[ERROR] symbol: class Test
[ERROR] location: class com.ayman.image.FileUploadTests
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[42,9] cannot find symbol
[ERROR] symbol: method given(java.util.stream.Stream<java.nio.file.Path>)
[ERROR] location: class com.ayman.image.FileUploadTests
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[47,25] cannot find symbol
[ERROR] symbol: variable Matchers
[ERROR] location: class com.ayman.image.FileUploadTests
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[46,28] cannot find symbol
[ERROR] symbol: method model()
[ERROR] location: class com.ayman.image.FileUploadTests
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[45,46] cannot find symbol
[ERROR] symbol: method status()
[ERROR] location: class com.ayman.image.FileUploadTests
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[45,26] cannot find symbol
[ERROR] symbol: method get(java.lang.String)
[ERROR] location: class com.ayman.image.FileUploadTests
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[53,9] cannot find symbol
[ERROR] symbol: class MockMultipartFile
[ERROR] location: class com.ayman.image.FileUploadTests
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[53,47] cannot find symbol
[ERROR] symbol: class MockMultipartFile
[ERROR] location: class com.ayman.image.FileUploadTests
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[57,28] cannot find symbol
[ERROR] symbol: method header()
[ERROR] location: class com.ayman.image.FileUploadTests
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[56,28] cannot find symbol
[ERROR] symbol: method status()
[ERROR] location: class com.ayman.image.FileUploadTests
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[55,26] cannot find symbol
[ERROR] symbol: method fileUpload(java.lang.String)
[ERROR] location: class com.ayman.image.FileUploadTests
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[59,9] cannot find symbol
[ERROR] symbol: method then(com.ayman.image.storage.StorageService)
[ERROR] location: class com.ayman.image.FileUploadTests
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[65,9] cannot find symbol
[ERROR] symbol: method given(org.springframework.core.io.Resource)
[ERROR] location: class com.ayman.image.FileUploadTests
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[68,60] cannot find symbol
[ERROR] symbol: method status()
[ERROR] location: class com.ayman.image.FileUploadTests
[ERROR] /C:/Users/workspace/SpringMVCImage/src/main/java/com/ayman/image/FileUploadTests.java:[68,26] cannot find symbol
[ERROR] symbol: method get(java.lang.String)
[ERROR] location: class com.ayman.image.FileUploadTests
[ERROR] -> [Help 1]
[ERROR]
Here is my pom.xml file
<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.ayman</groupId>
<artifactId>SpringMVCImage</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<start-class>com.ayman.image.Main</start-class>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.2.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- Spring Mobile -->
<dependency>
<groupId>org.springframework.mobile</groupId>
<artifactId>spring-mobile-device</artifactId>
<version>1.1.5.RELEASE</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
In Maven, test classes have not to be located in the src/main/java directory but in the src/test/java directory.
src/test/java is indeed the test source directory and only classes located here can use dependencies specified with the test scope.
So all your test classes using classes of this dependency cannot compile :
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
Move your test classes in src/test/java and it should solve a large part of your issue.
This introduction on the directory layout of Maven could probably help you.
Related
I can't build the maven Vaadin 11 starter pack like mentioned in the tutorial section of the doc. It seems that a package is missing, which provide an #Helper annotation. I tried to add the dependency in the pom.xml but no luck.
Here's the log from Maven :
-------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.653 s
[INFO] Finished at: 2018-09-15T11:30:01+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project my-starter-project: Compilation failure: Compilation failure:
[ERROR] /Users/olivierbatard/Java/Vaadin/my-starter-project/src/main/java/org/hammicus/vaadin/Customer.java:[5,44] package com.vaadin.flow.tutorial.annotations does not exist
[ERROR] /Users/olivierbatard/Java/Vaadin/my-starter-project/src/main/java/org/hammicus/vaadin/Customer.java:[12,2] cannot find symbol
[ERROR] symbol: class Helper
[ERROR] /Users/olivierbatard/Java/Vaadin/my-starter-project/src/main/java/org/hammicus/vaadin/CustomerStatus.java:[3,44] package com.vaadin.flow.tutorial.annotations does not exist
[ERROR] /Users/olivierbatard/Java/Vaadin/my-starter-project/src/main/java/org/hammicus/vaadin/CustomerStatus.java:[5,2] cannot find symbol
[ERROR] symbol: class Helper
[ERROR] /Users/olivierbatard/Java/Vaadin/my-starter-project/src/main/java/org/hammicus/vaadin/CustomerService.java:[12,44] package com.vaadin.flow.tutorial.annotations does not exist
[ERROR] /Users/olivierbatard/Java/Vaadin/my-starter-project/src/main/java/org/hammicus/vaadin/CustomerService.java:[21,2] cannot find symbol
[ERROR] symbol: class Helper
[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
When I add the dependency in the pom :
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.982 s
[INFO] Finished at: 2018-09-15T11:38:43+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project my-starter-project: Could not resolve dependencies for project org.hammicus.vaadin:my-starter-project:war:1.0-SNAPSHOT: Could not find artifact com.vaadin:flow-documentation-parent:jar:1.1-SNAPSHOT in Vaadin Directory (http://maven.vaadin.com/vaadin-addons) -> [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/DependencyResolutionException
Here is the pom.xml section with the dependency I added :
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>flow-documentation-parent</artifactId>
<version>1.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
Here is the link to the tutorial : https://vaadin.com/docs/v11/flow/introduction/tutorial-get-started.html
Does anyone know how to fix the dependency ?
You can remove all references to the #Helper annotation from the code. It's only used by our own internal tests that verify the tutorial code compiles.
I've created a ticket about fixing the tutorial and/or the code so that this shouldn't be an issue in the future.
When i compile my bdd frame work in java getting the following compilation error.I am new to this.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.
2:compile (default-compile) on project workflows.automation: Compilation
failure: Compilation failure:
[ERROR] /C:/OFFICIAL/BDDFramework/workflows.automation/src/main/java/bdd
/automation/pages/LoginPage.java:[23,1] package org.jbehave.core
.annotations does not exist
[ERROR] /C:/OFFICIAL/BDDFramework/workflows.automation/src/main/java/bdd
/automation/pages/LoginPage.java:[31,11] cannot find symbol
[ERROR] symbol: class BeforeStory
[ERROR] location: class bdd.automation.pages.LoginPage
[ERROR] -> [Help 1]
The error says that jbehave core is missing at compilation time. Add jbehave-core into your pom.xml as a new maven dependency.
See https://mvnrepository.com/artifact/org.jbehave/jbehave-core
This is the error I am getting.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project merchentsettlement: Compilation failure: Compilation failure:
[ERROR] Configuration.java:[163,76] cannot find symbol
[ERROR] symbol: method build()
[ERROR] location: class org.springframework.batch.core.step.builder.StepBuilderHelper
[ERROR] Configuration.java:[178,59] cannot find symbol
[ERROR] symbol: method build()
[ERROR] location: class org.springframework.batch.core.step.builder.StepBuilderHelper
[ERROR] -> [Help 1]
I download netty-socketio-demo from github.com, I cannot mvn install the server, I got error like
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project demo: Compilation failure: Compilation failure:
[ERROR] C:\Users\sun\git\netty-socketio-demo\server\src\main\java\com\corundumstudio\socketio\demo\NamespaceChatLauncher.java:[20,55] error: cannot find symbol
[ERROR] symbol: method sendJsonObject(ChatObject)
[ERROR] location: class BroadcastOperations
[ERROR] C:\Users\sun\git\netty-socketio-demo\server\src\main\java\com\corundumstudio\socketio\demo\NamespaceChatLauncher.java:[16,22] error: cannot find symbol
[ERROR] symbol: method addJsonObjectListener(Class<ChatObject>,<anonymous DataListener<ChatObject>>)
[ERROR] location: variable chat1namespace which type is SocketIONamespace
[ERROR] C:\Users\sun\git\netty-socketio-demo\server\src\main\java\com\corundumstudio\socketio\demo\NamespaceChatLauncher.java:[29,55] error: cannot find symbol
[ERROR] : METHOD sendJsonObject(ChatObject)
[ERROR] LOCATION: CLASS BroadcastOperations
[ERROR] C:\Users\sun\git\netty-socketio-demo\server\src\main\java\com\corundumstudio\socketio\demo\NamespaceChatLauncher.java:[25,22] error: cannot find symbol
[ERROR] -> [Help 1]
I've found dependencies in my mvn repository. I use command mvn clean install. Thanks for any help.
Change the pom.xml of the server folder:
<dependency>
<groupId>com.corundumstudio.socketio</groupId>
<artifactId>netty-socketio</artifactId>
<version>1.7.1</version>
</dependency>
To:
<dependency>
<groupId>com.corundumstudio.socketio</groupId>
<artifactId>netty-socketio</artifactId>
<version>1.6.5</version>
</dependency>
And re run maven
I'm trying to build Hue and it appears to require a Thrift binary that I am missing.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile
(default-compile) on project hue-plugins: Compilation failure: Compilation failure:
[ERROR] /Users/kramachandran/Sandbox/hue/hue/desktop/libs/hadoop/java/src/main/java/org/apache/hadoop/thriftfs/DatanodePlugin.java:[32,29] cannot find symbol
[ERROR] symbol : class BlockReader
[ERROR] location: package org.apache.hadoop.hdfs
[ERROR] /Users/kramachandran/Sandbox/hue/hue/desktop/libs/hadoop/java/src/main/java/org/apache/hadoop/thriftfs/DatanodePlugin.java:[33,39] cannot find symbol
[ERROR] symbol : class RemoteBlockReader
[ERROR] location: class org.apache.hadoop.hdfs.DFSClient
[ERROR] /Users/kramachandran/Sandbox/hue/hue/desktop/libs/hadoop/java/src/main/java/org/apache/hadoop/thriftfs/DatanodePlugin.java:[91,10] cannot find symbol
[ERROR] symbol: class BlockReader
[ERROR] BlockReader reader = null;
[ERROR] /Users/kramachandran/Sandbox/hue/hue/desktop/libs/hadoop/java/src/main/java/org/apache/hadoop/thriftfs/DatanodePlugin.java:[95,21] cannot find symbol
[ERROR] symbol: variable RemoteBlockReader
[ERROR] reader = RemoteBlockReader.newBlockReader(getSocket(), block.path, block.blockId,
However there is no documentation on how hue and thrift interact. Specifically, which versions of the thrift binaries are requrired and where they should be placed.
The dependencies are in the hue pom.xml file
<dependency>
<groupId>org.apache.thrift</groupId>
<artifactId>libthrift</artifactId>
<version>0.5.0-cdh</version>
</dependency>
<dependency>
<groupId>org.apache.thrift</groupId>
<artifactId>libfb303</artifactId>
<version>0.5.0-cdh</version>
</dependency>