How to remove unknown error from Spring Boot project - java

I have created spring boot project from spring initializer 2-times but getting unknown error. I have also removed .m2 folder and one time spring boot autoconfiguration folder even its not resolved.
when i hover mouse pointer to package on second image is shows error.
The type org.springframework.beans.factory.support.BeanNameGenerator
cannot be resolved. It is indirectly referenced from required .class
files
also tried with spring core and context dependencies.

I have created this project from spring initializr with version 2.4.1
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
When I down graded parent dependency version then its working and error gone
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
Other options not worked for me.

If you want to use spring boot version 2.4.1 use the below 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.4.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</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-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-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>
Right-click your project and click maven -> update project

BeanNameGenerator is provided by the spring-beans artifact. Make sure it is a dependency of your project.

Go to https://start.spring.io/ url.
Fill the project metdata information
Add the required dependencies
Click the Explore button
copy the XML and paste into your project pom.xml.
Right-click your project, click maven -> update project

Related

Spring boot azure project gives java.util.Comparator java.util.TreeMap.comparator accessible

I created a spring boot project with spring initializer and I'm following this tutorial here to setup azure. It's an empty project. mvn clean install, mvn clean package runs fine. The spring boot app also starts properly.
https://spring.io/guides/gs/spring-boot-for-azure/
The pom looks like this:
<?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>3.0.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.dasdsad</groupId>
<artifactId>myProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>myProject</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>19</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</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-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>
When I do ./mvnw com.microsoft.azure:azure-spring-cloud-maven-plugin:1.3.0:config
I get this error:
Unable to make field private final java.util.Comparator java.util.TreeMap.comparator accessible: module java.base does not "opens java.util" to unnamed module #67b61834
Does anyone have experience with this behavior?

Problem creating Spring framework project in IntelliJ

I am trying to create a Spring project using Spring initializer in IntelliJ ultimate edition according to the official guide of Jetbrains.
All steps go fine including installing the dependencies of the project.
But whenever I try to run the app; the error below shows up stating that "package org.springframework.boot does not exist" which is already installed in my dependencies.
I've gone through every related post to this problem but no luck. I would appreciate if anyone can guide me through this to figure out what it is that's going wrong about this.
This is also my pom.xml content provided 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.3.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>15</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>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
In the top right side you have got a refresh button to reinitialize the Pom.xml file again. Once maven repositories are all set it will allow you to start the project

spring initializer in spring boot application

I have generated a spring boot application with spring-initializer. when im building the project it gives an unknown error in pom.xml file.
Why is this happening and how to reslove it?error with 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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.research</groupId>
<artifactId>patients-api</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>patients-api</name>
<description>Demo project for Spring Boot</description>
<properties>
<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>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>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
it is not an error to worry about. Spring Boot 2.1.5.RELEASE has release just a week back and probably the IDE you are using for example STS may not be the latest one.
You have 2 options:
update your IDE & Maven and to the latest version [OR]
Simply change version <version>2.1.5.RELEASE</version> to <version>2.1.4.RELEASE</version> and do a Maven update on the project.
I had a similar issue and I fixed with the above options.
Hope this helps.

Eclipse showing "Maven Configuration Problem: Unknown"

I just imported a spingboot project that I created in https://start.spring.io/ in eclipse.
I tried to import two times, but the problem persists.
Already tried to do a mvn update , a mvn clean install, tried to clean the project but none of this worked.
Its a problem in the first line of pom xml file.
I dont have any idea how to solve this.
I'm using java 11
This is the complete POM 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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.in28minutes.springboot.rest.example</groupId>
<artifactId>spring-boot-2-jpa-with-hibernate-and-h2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>spring-boot-2-jpa-with-hibernate-and-h2</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</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-devtools</artifactId>
<scope>runtime</scope>
</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>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
This seems like a bug in eclipse:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=547340
You can fix this by temporary downgrading the maven jar plugin version to 3.1.1 from 3.1.2. Add this to the properties section:
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
So your pom will look like this:
<?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.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.in28minutes.springboot.rest.example</groupId>
<artifactId>spring-boot-2-jpa-with-hibernate-and-h2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>spring-boot-2-jpa-with-hibernate-and-h2</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.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-devtools</artifactId>
<scope>runtime</scope>
</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>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Update:
A fix has been released. Click Help > Check for updates in Eclipse/STS and install the newest m2e connector.
Step 1:
Downgrade to <maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
<properties>
<java.version>X</java.version>
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
</properties>
Step 2 Update Project
Right Click on your Project
Go to Maven
Click on Update Project
Clean and Re-Run your Application
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
Add this dependency in pom.xml under properties tag
For spring boot project I have added this:
<properties>
<java.version>1.8</java.version>
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
</properties>
Was Getting exact same error. Solution by Gybandi kinda worked for me.
Updating project in Maven> menu does nothing to make error icon go away.
Did the 3.1.1 and then did a maven -> update project from context menu. The red (x) icon is now GONE :-). But I really don't want to downgrade my maven plugin, if possible.
The suggestion of updating m2e-connector from eclipse marketplace
does not work. All I see against the m2e-connector entry is a "learn
more" link which takes me to its webpage. Nothing like
"upgrade/update" button present.
if you are using spring boot downgrade the version to 2.1.4.RELEASE instead of 2.1.5.RELEASE it will solve the problem
I am using eclipse photon and had similar issue. Didnt want to add the maven-jar-plugin.version in my pom as I dont want my codebase to contain code specific to IDE.
What I noticed is eclipse photon has m2e version of 1.5 which is causing the problem. I uninstall all the m2e connectors, restarted my eclipse and then installed the m2e connector using the below url manually
https://download.eclipse.org/technology/m2e/releases/1.13/
this worked like a charm
Adding packaging tag solved my problem. Didn't need to lower maven-jar plugin version.
<modelVersion>4.0.0</modelVersion>
<packaging>war</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.2.RELEASE</version>
<relativePath/>
</parent>
I fixed this issue by changing the version from 2.1.6 to 2.1.3
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
I changed this to 2.1.3 because there were two versions were shown available in local m2 repository at below path
.m2\repository\org\springframework\boot\spring-boot-starter-parent

How to build neo4j-jdbc driver from official repo?

I wanted to use the neo4j-jdbc (https://github.com/neo4j-contrib/neo4j-jdbc) to connect to my Neo4j 3.0 server. I'd like to build the driver myself so that I can add it to another project as a jar file. I'm struggling to understand the readme on the official repo.
Could someone please explain how to do this, I'm hoping to clone the repo and build in Eclipse. I understand how to clone the repo it's how you go about building the driver.
Many thanks,
As you said in the comments it seems that you want to simply connect to a Neo4j server, and as most people recommend you should use Maven or Gradle to work with your dependecies.
For that you're gonna need to create a new Maven Project:
and when you finish creating you're gonna have a project similar to this one, the one file you're looking to add this capability to connect to Neo4j is the pom.xml:
To be able to connect to Neo4j simply add this to the <dependencies></dependencies> tag:
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-jdbc</artifactId>
<version>3.0</version>
</dependency>
Here's an example of a pom.xml created automaticly by a Spring Starter Project:
<?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.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.6.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</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

Categories

Resources