Ok...for the first time in my life as a Developer I have no Idea how to fix this error.
I'm having issues with Maven commands and Intellij.
(IMPORTANT)
All maven commands on local project isn't working and returns the error:
cannot find or load main class #, java.lang.ClassNotFoundException: #
Detail for the "#" on the error message.
My pom.xml file is:
<?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.3.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>garantia.safra</groupId>
<artifactId>gateway</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>gateway</name>
<description>description</description>
<properties>
<java.version>11</java.version>
<start-class>garantia.safra.gateway.GatewayApplication</start-class>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</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-web</artifactId>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwd</artifactId>
<version>0.9.1</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</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>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
I tried to delete .m2/repository folder but it didn't work.
I tried to 'Settings > Build, execution, deployment > Build Tools > maven > Importing' and set the import as 'project JDK' but it didnt work. (I'm using JDK 11, and it was working before)
I tried to update the maven repositories by Intellij (remote and local) and now I have a error from remote repository (can't find any imported package classes)
The only thing I did that solve it once, was recreate the project as a new one and add all the classes and pom.xml, but when I added my configuration files it broke again.
I'm using a proxy from production (.maven/jvm.config)
# -Dhttp.proxyHost=<proxy_host>
# -Dhttp.proxyPort=<proxy_port>
# -Dhttps.proxyHost=<proxy_host>
# -Dhttps.proxyPort=<proxy_port>
But the lines are all commented right?
And application.properties:
server.address=0.0.0.0
So...This is being a very anoying problem, and I'm lack of ideas. Maybe I'm gonna try to recreate the project AGAIN and reimport each file to see which is the broken one, but if someone had this issue before and fixed it...how?
Empty or delete .maven/jvm.config file, it's loaded directly and added to the command line, the comments syntax is not supported.
Related
Problem Statement
I am receiving the following exception when I run my Spring Boot application.
***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.hibernate.cfg.AnnotationBinder.bindJoinedTableAssociation(AnnotationBinder.java:2548)
The following method did not exist:
javax.persistence.JoinTable.indexes()[Ljavax/persistence/Index;
The method's class, javax.persistence.JoinTable, is available from the following locations:
jar:file:/C:/Users/Usuario/IdeaProjects/spring-security/lib/javax.persistence.jar!/javax/persistence/JoinTable.class
jar:file:/C:/Users/Usuario/.m2/repository/jakarta/persistence/jakarta.persistence-api/2.2.3/jakarta.persistence-api-2.2.3.jar!/javax/persistence/JoinTable.class
The class hierarchy was loaded from the following locations:
javax.persistence.JoinTable: file:/C:/Users/Usuario/IdeaProjects/spring-security/lib/javax.persistence.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of javax.persistence.JoinTable
Process finished with exit code 1
Below is the contents of my 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 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.5.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>spring-security</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>spring-security</name>
<description>spring-security</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</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-web</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity5</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
How to I remove one of the versions of javax.persistence.JoinTable?
Multiple javax.persistence.JoinTable
The issue is most likely related to the duplicate javax.persistence.* libraries. I see you have the following two dependencies
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
Remove the org.springframework.data.spring-data-jpa dependency.
The org.springframework.boot.spring-boot-starter-data-jpa dependency already includes org.springframework.data.spring-data-jpa which is being added transitively.
Make sure to run a mvn clean before packaging and testing the new jar file
Non Maven lib directory
It also looks like there is a lib directory in your project that may have dependencies that are not managed by Maven. Please delete at least the javax.persistence library from that location
I moved some files into new packages so that things would make more sense, but this has resulted in my dependencies getting messed up.
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
These lines give "cannot resolve symbol 'springframework'" with the advice of adding a maven dependency. If I do this nothing changes within the pom.xml file. Also the pom has errors with "spring-boot-starter-frontData-jpa" and "org.springframework.frontData" saying dependency not found.
Everything worked fine before but is messed up now. I've tried invalidate & restart which doesn't solve anything, undoing the changes also doesn't seem to work. Does anyone have an idea on this? The pom.xml file can be found below. Also might be important I'm working on intellij.
<?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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>be.uantwerpen.idlab.dust</groupId>
<artifactId>initializr</artifactId>
<version>0.1</version>
<name>dust-initializr</name>
<description></description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-frontData-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</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>org.springframework.frontData</groupId>
<artifactId>spring-frontData-rest-core</artifactId>
<version>3.1.5.RELEASE</version>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ainslec</groupId>
<artifactId>picocog</artifactId>
<version>1.0.7</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<finalName>dust-initializr</finalName>
</configuration>
</plugin>
</plugins>
</build>
</project>
I've solved this by reverting changes through git.
Re-doing the moves didn't give the same error this time.
Not shure where this error came from and advice is welcome should it happen again.
I created a maven-based spring-boot-project to explore how to make it run on a Websphere Application Server.
This is way I need to exclude the Embedded Tomcat of spring-boot-starter-web.
I've tried the following things:
Added a new dependency for spring-boot-starter-tomcat with the scope: provided (see Removing embedded tomcat server from war file when deploying to JBOSS [Spring-Boot]) followed by a mvn clean update.
Used the exclusions-tag in the spring-boot-starter-web dependency to exclude spring-boot-starter-tomcat (see https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html) followed by a mvn clean update.
Neither of those works.
Here is my 'native' 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 http://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.1.6.RELEASE</version>
<relativePath/>
</parent>
<packaging>war</packaging>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
...
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
This is my dependency with explicit Tomcat (scope: provided):
<project ...>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
This is my dependency with the exclusion:
<project ...>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring‑boot‑starter‑tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
This is the output of mvn dependency:tree:
https://imgur.com/a/VUkYCLm
(Sorry I don't know how to upload pictures here.)
I'd expect the Tomcat to be removed from my maven dependencies.
Thanks in advance.
Running your exclusions example that you posted ran fine when i build it .
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
Also I did mvn clean install after adding this exclusion and my dependency tree also doesn't include tomcat jar anymore :
Did you mvn clean install after adding the exclusions ?
Hi. I'm studying Java Web and created an application using Spring Boot and Maven.
The application is working fine using mvn spring-boot:run.
How do I compile or build it to send it to someone?
Hi. I'm studying Java Web and created an application using Spring Boot and Maven.
The application is working fine using mvn spring-boot:run.
How do I compile or build it to send it to someone?
(I'm not sure why Stackoverflow is asking for more commentary)
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>Paulo</groupId>
<artifactId>Patients</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Patients</name>
<description></description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<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-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.11.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.3.11.Final</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
In your pom.xml if spring-boot-maven-plugin is not available then first make sure that, it is available in your pom.xml(you already do that).
Spring-boot project outcome is a simple jar file. This jar file include all the file it needed, embedded tomcat etc.
Go to your project directory from command line. Say for example your project root folder name is ABC, then go to /ABC folder and run the command.
mvn package
After running this command successfully, you find a folder named /target. Inside the /target folder your find your jar file. Run the jar using java -jar ABC.jar command or share your jar with others.
If you want to create an installer for your application you can use
IzPack Maven Plugin
I've spent the past two days attempted to get Spring Boot to work. However, I have been unable to get a brand new, clean project to run inside of IntelliJ Idea.
Here's what I'm doing:
Open IntelliJ Idea
Create a new project with Spring Initializr with the dependencies Security, Web, Rest Repositories, JPA, H2, and Actuator.
Run the Java file called Application.java
Get this output.
(╯°□°)╯︵ ┻━┻
Here is 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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.aroid</groupId>
<artifactId>restserver</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>AroidRESTServer</name>
<description>Aroid REST Server</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.7.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<!-- Start what I added -->
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<version>2.2.4</version>
</dependency>
<!-- End what I added -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
<version>1.2.7.RELEASE</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Note: I have a section in the dependencies where I label the things I added by hand. These are things that Spring Initializr did not automatically add (and should have), so I needed to add them manually to get the project to run.
I believe the issue has to do with my IntelliJ Idea setup, since running a new project in STS (Spring Tool Suite) runs fine.
Some other things I've tried and still getting the same result:
Using the web version of Spring Initializr.
Creating a new Spring Boot project without any libraries
Downloading sample projects and running them.
Adding dependencies that have this library manually via Maven.
Creating then project in STS and importing it into IntelliJ Idea.
Basically anything within the first ten pages of Google Search results for the issue.
Any help would be quite helpful.
Thanks,
Nathan