How do I add springframework dependancy in java, maven, intellij - java

I've just barely started a java 8 project with spring boot and maven. I can't add the springframework dependancy...
When I go over it with the mouse and click on "Add dependancy" nothing changes, even after loading the maven changes.
Here's my pom.xml
<?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.7.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>microservices.book</groupId>
<artifactId>social-multiplication</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>social-multiplication</name>
<description>Social Multiplication App</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>5.3.20</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test</artifactId>
<version>2.6.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<version>2.7.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
EDIT:
mvn clean package
[INFO] Scanning for projects...
[INFO]
[INFO] --------------< microservices.book:social-multiplication >--------------
[INFO] Building social-multiplication 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.2.0:clean (default-clean) # social-multiplication ---
[INFO] Deleting C:\Users\username\Desktop\Programming\social-multiplication\target
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) # social-multiplication ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.10.1:compile (default-compile) # social-multiplication ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 4 source files to C:\Users\username\Desktop\Programming\social-multiplication\target\classes
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:testResources (default-testResources) # social-multiplication ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] skip non existing resourceDirectory C:\Users\username\Desktop\Programming\social-multiplication\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.10.1:testCompile (default-testCompile) # social-multiplication ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to C:\Users\username\Desktop\Programming\social-multiplication\target\test-classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/username/Desktop/Programming/social-multiplication/src/test/java/microservices/book/multiplication/SocialMultiplicatio
nApplicationTests.java:[3,17] package org.junit does not exist
[ERROR] /C:/Users/username/Desktop/Programming/social-multiplication/src/test/java/microservices/book/multiplication/SocialMultiplicatio
nApplicationTests.java:[4,24] package org.junit.runner does not exist
[ERROR] /C:/Users/username/Desktop/Programming/social-multiplication/src/test/java/microservices/book/multiplication/SocialMultiplicatio
nApplicationTests.java:[10,10] cannot find symbol
symbol: class Test
location: class test.java.microservices.book.multiplication.SocialMultiplicationApplicationTests
[INFO] 3 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.838 s
[INFO] Finished at: 2022-09-12T21:36:28+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:testCompile (default-testCompile) on project socia
l-multiplication: Compilation failure: Compilation failure:
[ERROR] /C:/Users/username/Desktop/Programming/social-multiplication/src/test/java/microservices/book/multiplication/SocialMultiplicatio
nApplicationTests.java:[3,17] package org.junit does not exist
[ERROR] /C:/Users/username/Desktop/Programming/social-multiplication/src/test/java/microservices/book/multiplication/SocialMultiplicatio
nApplicationTests.java:[4,24] package org.junit.runner does not exist
[ERROR] /C:/Users/username/Desktop/Programming/social-multiplication/src/test/java/microservices/book/multiplication/SocialMultiplicatio
nApplicationTests.java:[10,10] cannot find symbol
[ERROR] symbol: class Test
[ERROR] location: class test.java.microservices.book.multiplication.SocialMultiplicationApplicationTests
[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
.idea.log file contents:
2022-09-12 21:36:41,468 [ 502853] WARN - com.intellij.util.xmlb.Binding - no accessors for org.jetbrains.kotlin.idea.scripting.gradle.GradleScriptInputsWatcher$Storage

Related

Push to github rejected with maven-release-plugin

I've spent hours trying to release a project to github with Maven. This is usually not a problem but for some reason it is for this project and I don't understand why. I'm using Maven 3.8.5 with Java 1.8.0_312 and git 2.36.1. Here's the pom.xml file:
<?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>se.company.myproject</groupId>
<artifactId>myproject</artifactId>
<version>4.0.0</version>
<packaging>pom</packaging>
<name>myproject-base</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<slf4j.version>1.7.36</slf4j.version>
</properties>
<modules>
<module>module1</module>
<module>module2</module>
<module>module3</module>
</modules>
<scm>
<connection>scm:git:ssh://git#github.com/mycompany/myproject.git</connection>
<developerConnection>scm:git:ssh://git#github.com/mycompany/myproject.git</developerConnection>
<url>https://github.com/mycompany/myproject.git</url>
<tag>4.0.0</tag>
</scm>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>se.company.myproject</groupId>
<artifactId>some-internal-dependency</artifactId>
<version>5.0.1</version>
</dependency>
<!-- Test dependencies -->
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.9.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<tagNameFormat>#{project.version}</tagNameFormat>
<autoVersionSubmodules>true</autoVersionSubmodules>
</configuration>
</plugin>
</plugins>
</build>
<distributionManagement>
<repository>
<id>company-releases</id>
<name>Internal Releases</name>
<url>https://company.se/company-maven-releases/</url>
</repository>
<snapshotRepository>
<id>company-snapshots</id>
<name>Internal Snapshots</name>
<url>https://company.se/company-maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
<repositories>
<repository>
<id>company-releases</id>
<url>https://company.se/company-maven-releases/</url>
</repository>
</repositories>
</project>
When I run maven release:prepare I get this:
[INFO] [INFO] --- maven-jar-plugin:2.4:jar (default-jar) # myproject-module3 ---
[INFO] [INFO] Building jar: /Users/me/code/module3/target/myproject-module3-4.0.0.jar
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Reactor Summary for myproject-base 4.0.0:
[INFO] [INFO]
[INFO] [INFO] myproject-base ..................................... SUCCESS [ 0.059 s]
[INFO] [INFO] module1............................................. SUCCESS [ 1.097 s]
[INFO] [INFO] module2 ............................................ SUCCESS [ 0.603 s]
[INFO] [INFO] module3 ............................................ SUCCESS [ 0.046 s]
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] BUILD SUCCESS
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Total time: 1.878 s
[INFO] [INFO] Finished at: 2022-05-20T14:29:16+02:00
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [prepare] 11/17 scm-commit-release
[INFO] Checking in modified POMs...
[INFO] Executing: /bin/sh -c cd '/Users/me/code/myproject' && 'git' 'add' '--' 'pom.xml' 'module1/pom.xml' 'module2/pom.xml' 'module3/pom.xml'
[INFO] Working directory: /Users/me/code/myproject
[INFO] Executing: /bin/sh -c cd '/Users/me/code/myproject' && 'git' 'rev-parse' '--show-prefix'
[INFO] Working directory: /Users/me/code/myproject
[INFO] Executing: /bin/sh -c cd '/Users/me/code/myproject' && 'git' 'status' '--porcelain' '.'
[INFO] Working directory: /Users/me/code/myproject
[WARNING] Ignoring unrecognized line: ?? module1/pom.xml.releaseBackup
[WARNING] Ignoring unrecognized line: ?? module2/pom.xml.releaseBackup
[WARNING] Ignoring unrecognized line: ?? pom.xml.releaseBackup
[WARNING] Ignoring unrecognized line: ?? release.properties
[WARNING] Ignoring unrecognized line: ?? module3/pom.xml.releaseBackup
[INFO] Executing: /bin/sh -c cd '/Users/me/code/myproject' && 'git' 'commit' '--verbose' '-F' '/var/folders/xb/pl4xth9n5qbgksbyy2fy5lm80000gn/T/maven-scm-1737591658.commit'
[INFO] Working directory: /Users/me/code/myproject
[INFO] Executing: /bin/sh -c cd '/Users/me/code/myproject' && 'git' 'symbolic-ref' 'HEAD'
[INFO] Working directory: /Users/me/code/myproject
[INFO] Executing: /bin/sh -c cd '/Users/me/code/myproject' && 'git' 'push' 'ssh:********#github.com/company/myproject.git' 'refs/heads/main:refs/heads/main'
[INFO] Working directory: /Users/me/code/myproject
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for myproject-base 3.0.1-SNAPSHOT:
[INFO]
[INFO] myproject-base ........................................ FAILURE [ 8.100 s]
[INFO] module1 ............................................... SKIPPED
[INFO] module2 ............................................... SKIPPED
[INFO] module3 ............................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.207 s
[INFO] Finished at: 2022-05-20T14:29:18+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:3.0.0-M5:prepare (default-cli) on project myproject: Unable to commit files
[ERROR] Provider message:
[ERROR] The git-push command failed.
[ERROR] Command output:
[ERROR] To ssh://github.com/company/myproject.git
[ERROR] ! [rejected] main -> main (non-fast-forward)
[ERROR] error: failed to push some refs to 'ssh://github.com/company/myproject.git'
[ERROR] hint: Updates were rejected because the tip of your current branch is behind
[ERROR] hint: its remote counterpart. Integrate the remote changes (e.g.
[ERROR] hint: 'git pull ...') before pushing again.
[ERROR] hint: See the 'Note about fast-forwards' in 'git push --help' for details.
[ERROR]
[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
I can push (and pull) just fine from the command line by using the git command. I've tried different versions of the maven-release-plugin to no avail. I've even deleted the entire GitHub repository and pushed it again from my local machine but still, I get the same error. What could be causing this?
A mvn -X prepare should show you which commit is checked out from your git:ssh://git#github.com/mycompany/myproject.git
Compare it with the latest commit on GitHub to understand the difference.
Trying to use an exec goal to do a git pull before mvn release is possible, but it is better to identify first why there is a remote commit that you do not have locally.

How to export packages and classes to a test module in a Java app?

I want to build a multi-modules SpringBoot app with following modules :
App : the Parent module, Main class is here
Model : all Domain objects, no Main class, no tests
Tests : dedicated to whole app tests, will have Cucumber tests
My problem is :
I actually can run unit tests on Model's objects in Tests module, but doing a mvn clean install on App module fails because Tests module doesn't know anything about Model's objects.
In one hand, Spring makes the job, importing all needed classes
from Model module and running tests on them.
In the other hand, Maven cries with the following error :
package com.my-app.model.my-package does not exist.
OK, Spring and Maven are 2 different tools but what should I do in the App's POM to explicitely declare that all objects from the Model module should be exported to Tests module in order to be tested ?
<?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.4.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.humanresources.game</groupId>
<artifactId>hrg-app</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Application</name>
<description>Human Resources game engine</description>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<modules>
<module>../hrg-model</module>
<module>../hrg-tests</module>
</modules>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
<mainClass>HrgAppApplication</mainClass>
<goal>package</goal>
</configuration>
</plugin>
</plugins>
</build>
</project>
The Tests' module POM only declares a <dependency> block on Model Module.
Neither Tests module nor Model one have any <build> block in their respective POM.
As seen here, everything should only be managed by App's POM.
So my question is : what should I add in the App's POM <build> block to effectively export all Model's packages and classes to Tests module so that it remains possible to mvn clean install the whole project ?
Thanx by advance.
Edit : POM.xml for Tests and Model modules
Tests / 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>com.humanresources.game</groupId>
<artifactId>hrg-app</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../hrg-app/pom.xml</relativePath>
</parent>
<artifactId>hrg-tests</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Tests</name>
<description>Tests project</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>com.humanresources.game</groupId>
<artifactId>hrg-model</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Model / 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>com.humanresources.game</groupId>
<artifactId>hrg-app</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../hrg-app/pom.xml</relativePath>
</parent>
<artifactId>hrg-model</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Model</name>
<description>Tests project for Human Resources game</description>
<properties>
<java.version>1.8</java.version>
</properties>
</project>
Console Output after mvn clean install (unit test succeeds though) :
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] Application [pom]
[INFO] Model [jar]
[INFO] Tests [jar]
[INFO]
[INFO] ------------------< com.humanresources.game:hrg-app >-------------------
[INFO] Building Application 1.0-SNAPSHOT [1/3]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) # hrg-app ---
[INFO]
[INFO] --- spring-boot-maven-plugin:2.4.3:repackage (repackage) # hrg-app ---
[INFO]
[INFO] --- maven-install-plugin:2.5.2:install (default-install) # hrg-app ---
[INFO] Installing C:\Users\Fred\IdeaProjects\HumanResources\hrg-app\pom.xml to C:\Users\Fred\.m2\repository\com\humanresources\game\hrg-app\1.0-SNAPSHOT\hrg-app-1.0-SNAPSHOT.pom
[INFO]
[INFO] -----------------< com.humanresources.game:hrg-model >------------------
[INFO] Building Model 0.0.1-SNAPSHOT [2/3]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) # hrg-model ---
[INFO] Deleting C:\Users\Fred\IdeaProjects\HumanResources\hrg-model\target
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) # hrg-model ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) # hrg-model ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 11 source files to C:\Users\Fred\IdeaProjects\HumanResources\hrg-model\target\classes
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:testResources (default-testResources) # hrg-model ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] skip non existing resourceDirectory C:\Users\Fred\IdeaProjects\HumanResources\hrg-model\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) # hrg-model ---
[INFO] Changes detected - recompiling the module!
[INFO]
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) # hrg-model ---
[INFO]
[INFO] --- maven-jar-plugin:3.2.0:jar (default-jar) # hrg-model ---
[INFO] Building jar: C:\Users\Fred\IdeaProjects\HumanResources\hrg-model\target\hrg-model-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:2.4.3:repackage (repackage) # hrg-model ---
[INFO] Replacing main artifact with repackaged archive
[INFO]
[INFO] --- maven-install-plugin:2.5.2:install (default-install) # hrg-model ---
[INFO] Installing C:\Users\Fred\IdeaProjects\HumanResources\hrg-model\target\hrg-model-0.0.1-SNAPSHOT.jar to C:\Users\Fred\.m2\repository\com\humanresources\game\hrg-model\0.0.1-SNAPSHOT\hrg-model-0.0.1-SNAPSHOT.jar
[INFO] Installing C:\Users\Fred\IdeaProjects\HumanResources\hrg-model\pom.xml to C:\Users\Fred\.m2\repository\com\humanresources\game\hrg-model\0.0.1-SNAPSHOT\hrg-model-0.0.1-SNAPSHOT.pom
[INFO]
[INFO] -----------------< com.humanresources.game:hrg-tests >------------------
[INFO] Building Tests 0.0.1-SNAPSHOT [3/3]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) # hrg-tests ---
[INFO] Deleting C:\Users\Fred\IdeaProjects\HumanResources\hrg-tests\target
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) # hrg-tests ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) # hrg-tests ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\Users\Fred\IdeaProjects\HumanResources\hrg-tests\target\classes
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:testResources (default-testResources) # hrg-tests ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] skip non existing resourceDirectory C:\Users\Fred\IdeaProjects\HumanResources\hrg-tests\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) # hrg-tests ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\Users\Fred\IdeaProjects\HumanResources\hrg-tests\target\test-classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/Fred/IdeaProjects/HumanResources/hrg-tests/src/test/java/com/humanresources/game/hrgtests/HrgTestsApplicationTests.java:[3,42] package com.humanresources.game.model.card does not exist
[ERROR] /C:/Users/Fred/IdeaProjects/HumanResources/hrg-tests/src/test/java/com/humanresources/game/hrgtests/HrgTestsApplicationTests.java:[4,47] package com.humanresources.game.model.territory does not exist
[ERROR] /C:/Users/Fred/IdeaProjects/HumanResources/hrg-tests/src/test/java/com/humanresources/game/hrgtests/HrgTestsApplicationTests.java:[5,47] package com.humanresources.game.model.territory does not exist
[INFO] 3 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Application 1.0-SNAPSHOT ........................... SUCCESS [ 1.533 s]
[INFO] Model 0.0.1-SNAPSHOT ............................... SUCCESS [ 5.104 s]
[INFO] Tests 0.0.1-SNAPSHOT ............................... FAILURE [ 3.715 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.771 s
[INFO] Finished at: 2021-02-21T18:33:11+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:testCompile (default-testCompile) on project hrg-tests: Compilation failure: Compilation failure:
[ERROR] /C:/Users/Fred/IdeaProjects/HumanResources/hrg-tests/src/test/java/com/humanresources/game/hrgtests/HrgTestsApplicationTests.java:[3,42] package com.humanresources.game.model.card does not exist
[ERROR] /C:/Users/Fred/IdeaProjects/HumanResources/hrg-tests/src/test/java/com/humanresources/game/hrgtests/HrgTestsApplicationTests.java:[4,47] package com.humanresources.game.model.territory does not exist
[ERROR] /C:/Users/Fred/IdeaProjects/HumanResources/hrg-tests/src/test/java/com/humanresources/game/hrgtests/HrgTestsApplicationTests.java:[5,47] package com.humanresources.game.model.territory does not exist
See a screen capture after mvn clean install :
Problem Diagnostics
The output for the Maven execution contains the following lines for the hrg-model:
[INFO] --- spring-boot-maven-plugin:2.4.3:repackage (repackage) # hrg-model ---
[INFO] Replacing main artifact with repackaged archive
The JAR artifact of hrg-model is not a usual library after that, but an executable JAR packaged as described in the Spring Boot documentation
That executable JAR is not suitable for consumption by a Java compiler - or compiler for any other JVM-based language for that matter.
Solution
Only the Maven module which represents the final executable artifact of the project should include the invocation of the spring-boot-maven-plugin.
Please note, that your project has no such module at the moment.
I would suggest:
adding the new module with hrg-app as a parent and hrg-model as a dependency;
moving the spring-boot-maven-plugin invocation from the hrg-app module to the new module.
You may check the official guide from Spring Boot - Creating a Multi Module Project - for a step-by-step guide and explanation.
Try adding this plugin in your APPs pom.xml under plugins section of the XML's build element.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version><--your maven version--></version>
</plugin>

Running scala under maven project

i am running scala project .I woudld like to use maven project but , it seems doesn't recognize scala .Because before i used add scala nature now i would ike to add scala through maven , but i can't get it doesnt .i used scala 2.11.8
here is the pom.xml
<?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>SynchData</groupId>
<artifactId>SynchData</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-catalyst_2.11</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.11</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql_2.11</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql_2.11</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.1.3</version>
</dependency>
<!-- <dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId>
<version>9.2-1002-jdbc4</version> </dependency> -->
<!-- https://mvnrepository.com/artifact/oracle/ojdbc6 -->
<dependency>
<groupId>oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Once i make maven clean install i got this
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for SynchData:SynchData:jar:0.0.1-SNAPSHOT
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: org.apache.spark:spark-sql_2.11:jar -> duplicate declaration of version 2.2.0 # line 31, column 15
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building SynchData 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # SynchData ---
[INFO] Deleting C:\Users\MHT\eclipse-workspace\test.iptech\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # SynchData ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.6.1:compile (default-compile) # SynchData ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 1 source file to C:\Users\MHT\eclipse-workspace\test.iptech\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/MHT/eclipse-workspace/test.iptech/src/main/java/LauncherPack/SynchronizeData.java:[2,1] package SynchronizePackage does not exist
[ERROR] /C:/Users/MHT/eclipse-workspace/test.iptech/src/main/java/LauncherPack/SynchronizeData.java:[10,17] cannot find symbol
symbol: variable MainFunction
location: class LauncherPack.SynchronizeData
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.277 s
[INFO] Finished at: 2017-09-26T14:29:59+01:00
[INFO] Final Memory: 36M/281M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.1:compile (default-compile) on project SynchData: Compilation failure: Compilation failure:
[ERROR] /C:/Users/MHT/eclipse-workspace/test.iptech/src/main/java/LauncherPack/SynchronizeData.java:[2,1] package SynchronizePackage does not exist
[ERROR] /C:/Users/MHT/eclipse-workspace/test.iptech/src/main/java/LauncherPack/SynchronizeData.java:[10,17] cannot find symbol
[ERROR] symbol: variable MainFunction
[ERROR] location: class LauncherPack.SynchronizeData
[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
Please any help to get it work without using add scala nature through eclipse .
Thanks a lot

Maven Plugin/Profile Issue

I am an automation qa engineer and I've been charged with setting up our Jenkins CI framework. The issue that I am having is that Maven is failing in the build phase. In looking at the log there a few things that are concerning to me but I am not sure if they are related or relevant. See the log below
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\dmohamed>mvn test -PCustomerFSNRegressionSuite
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for
Envi_Test:Maven:jar:0.0.1-SNAPSHOT
[WARNING] 'dependencies.dependency.systemPath' for com.qas.qtest.api:qtest-sdk-a
gent:jar should not point at files within the project directory, ${basedir}\src\
Libs\qtest-sdk-java-1.1.0.jar will be unresolvable by dependent projects # line
42, column 17
[WARNING] 'dependencies.dependency.systemPath' for com.qas.qtest.api:qtest-testn
g-agent:jar should not point at files within the project directory, ${basedir}\s
rc\Libs\qtest-testng-agent-1.0.0.jar will be unresolvable by dependent projects
# line 50, column 17
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten t
he stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support buildin
g such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # Maven ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\dmohamed\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # Maven ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # Ma
ven ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\dmohamed\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # Maven -
--
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.19.1:test (default-test) # Maven ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.190 s
[INFO] Finished at: 2016-08-02T08:25:01-04:00
[INFO] Final Memory: 11M/307M
[INFO] ------------------------------------------------------------------------
[WARNING] The requested profile "CustomerFSNRegressionSuite" could not be activa
ted because it does not exist.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.
19.1:test (default-test) on project Maven: Unable to parse configuration of mojo
org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test for parameter proper
ties: Missing name in properties -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[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 rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginConfigur
ationException
C:\Users\dmohamed>
my concerns are specifically these lines
INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\dmohamed\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # Maven ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # Ma
ven ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory
C:\Users\dmohamed\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # Maven -
--
[INFO] No sources to compile
WARNING] The requested profile "CustomerFSNRegressionSuite" could not be activa
ted because it does not exist.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.
19.1:test (default-test) on project Maven: Unable to parse configuration of mojo
org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test for parameter proper
ties: Missing name in properties -> [Help 1]
It seems as though when I attempt to run the mvn commands it tries to reference srs folders that don't exist (not sure if this does any harm) it doesn't recognize my TestnNG profile specified in my POM file (I am assuming this will impact Jenkins) and there is some property/configuration error in my pom file (Per the ERROR message in my log) that I cannot resolve. See my POM file below
<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>Envi_Test</groupId>
<artifactId>Maven</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Maven</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<profiles>
<profile>
<id>CustomerFSNRegressionSuite</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-chrome-driver -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-testng</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>2.53.0</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-testng</artifactId>
<version>1.1.5</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
Any help would be greatly appreciated, I am sorry if this is a repost, I looked but I did not see a question regarding a circumstance like this.

Error while compiling apache sparkSql

I am trying to execute below sparkSQL example,
https://github.com/apache/spark/blob/master/examples/src/main/java/org/apache/spark/examples/sql/JavaSparkSQL.java
my pom.xml (i have added sql dependency as well, i am stuck please help)
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>edu.berkeley</groupId>
<artifactId>simple-project</artifactId>
<packaging>jar</packaging>
<version>1.0</version>
<name>Simple Project</name>
<repositories>
<repository>
<id>Akka repository</id>
<url>http://repo.akka.io/releases</url>
</repository>
</repositories>
<dependencies>
<dependency> <!-- Spark dependency -->
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.10</artifactId>
<version>1.0.2</version>
</dependency>
<dependency> <!-- Spark dependency -->
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql_2.10</artifactId>
<version>1.0.2</version>
</dependency>
</dependencies>
</project>
i have just renamed the file as SimpleApp.java
I get this following error when compiling.. kindly advice
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Simple Project 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # simple-project ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Volumes/Official/spark-1.0.2-bin-hadoop2/try/simple-project/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) # simple-project ---
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 1 source file to /Volumes/Official/spark-1.0.2-bin-hadoop2/try/simple-project/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Volumes/Official/spark-1.0.2-bin-hadoop2/try/simple-project/src/main/java/SimpleApp.java:[61,16] error: cannot find symbol
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.801 s
[INFO] Finished at: 2014-08-19T10:30:31+05:30
[INFO] Final Memory: 21M/232M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project simple-project: Compilation failure
[ERROR] /Volumes/Official/spark-1.0.2-bin-hadoop2/try/simple-project/src/main/java/SimpleApp.java:[61,16] error: cannot find symbol
[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
I found out the issue:
In the example
https://github.com/apache/spark/blob/master/examples/src/main/java/org/apache/spark/examples/sql/JavaSparkSQL.java
replace the line schemaPeople.registerTempTable("people");
with schemaPeople.registerAsTable("people");
compile and package with mvn compile and mvn package and run with
bin/spark-submit --class "org.apache.spark.examples.sql.SimpleApp" --master local[4] try/simple-project/target/simple-project-1.0.jar

Categories