The import org issue in spring java project - java

I am a novice to java and novice to spring as well...
I am creating my first java spring application using following link:
https://www.tutorialspoint.com/spring/spring_hello_world_example.htm
But I am getting this error on MainApp.jav-
The import org cannot be resolved.
Please see link given for steps i followed.
Please note I am not creating maven project.
Please help...

You have to add dependencies in your pom file , for imports. When you add a dependency , a jar file gets added in your maven or any other project, then you can import the org you want.

Issue resolved !
What i did - removed the import references and resolved it automatically by its class names.

You need to have the dependencies in the project in order to get the import statements.
add this to the pom.xml in to resolve the issue.
<properties>
<org.springframework.version>3.0.5.RELEASE</org.springframework.version>
</properties>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.context</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.web.servlet</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.transaction</artifactId>
<version>${org.springframework-version}</version>
</dependency>

Related

infinispan-query is not importing with maven

Hi I'm trying out to import infinispan-query dependency to my project.
<version.infinispan>5.2.8.Final</version.infinispan>
<version.infinispan-query>5.2.8.Final</version.infinispan-query>
................
<!-- https://mvnrepository.com/artifact/org.infinispan/infinispan-core -->
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-core</artifactId>
<version>${version.infinispan}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.infinispan/infinispan-query -->
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-query</artifactId>
<version>${version.infinispan-query}</version>
</dependency>
Here is part of my pom.xml where I've added the dependencies, the infinispan-core dependency it's imported, but I don't know why the infinispan-query dependency it's not imported.
Any help please? Thanks!
You might try to add JBoss Public Repository to your pom (or settings.xml). Both artifacts seem to be there (infinispan-core, infinispan-query). More information how to do that you might find in Maven's Guide.

EnableTransactionManagement cannot be resolved to a type 2

I am having problem "EnableTransactionManagement cannot be resolved to a type" though I have spring-tx jar already in my project. Can someone please suggest me what I am doing wrong. I am using Hibernate 4, Eclipse, Spring version 4.3.2. I am posting snapshot of my problem.
Thankyou!
You need to add spring-orm dependency into your pom.xml file.
<!-- https://mvnrepository.com/artifact/org.springframework/spring-orm -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>4.3.3.RELEASE</version>
</dependency>

cannot access org.springframework.core.env.EnvironmentCapable

I'm trying to get a spring bean in a web application using it:
WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());
AClass aClass = (aClass) wac.getBean("aClass");
And, when I run compile/test/package with maven, an error occurs:
cannot access org.springframework.core.env.EnvironmentCapable
[ERROR] class file for org.springframework.core.env.EnvironmentCapable not found
The most strange is that org.springframework.core.env.EnvironmentCapable exists! :/
Basic Project Configuration:
Spring 3.1.1.RELEASE (There isn't other spring version in classpath)
Maven 3
JSF 2.1
Servlet API 2.5
Any idea is welcome!
Finally, I've solved it! :)
In the pom.xml file, I had to define the scope of spring's dependencies to compile. (Yes, I know that is the default scope of dependencies but for some reason maven was not capable of the job). See a piece of my pom.xml that made the problem disapear:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
<scope>compile</scope>
</dependency>
Note that:
If you're having this problem, make sure that you're using a spring
version 3.1 or higher.
Remember that ${spring.version}, in my case, is 3.1.1.RELEASE.
I hope that it helps more people.
I was facing the exact same issue, maven complains from org.springframework.core.env.EnvironmentCapable, even with the file there, inside the jar: C:\Users\fabio\.m2\repository\org\springframework\spring-core\4.3.12.RELEASE\spring-core-4.3.12.RELEASE.jar.
The solution im my case was delete the .m2 folder, so maven downloaded all the jars again. Maybe it was some currupted file.
I hope it helps some one!
Me too face this issue. I used Spring 4.1.6 with maven 3 along with RabbitMQ.
<dependency>
<groupId>org.springframework.amqp</groupId>
<artifactId>spring-amqp</artifactId>
<version>1.1.4.RELEASE</version>
</dependency>
This dependency forced tomcat to die and showing these issue. I havn't gotten why it is making trouble. but finally I explicitly include jar in lib folder and this is how I resolved this issue.
Add this dependency to the pom.xml .You can fixed it.
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>1.4.2.RELEASE</version>
</dependency>
As I imported a project from GitHub without checking its spring-boot version had caused me the same problem, thus changing spring-boot version has resolved my problem, I was using version 1.1.4 moving to 2.2.5 (or latest releases ) will download all the needed dependencies
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.5.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>

Cannot find spring 4 maven artifact

According to the springio documentation here I should be able to just cut and paste this...
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework</artifactId>
<version>4.0.5.RELEASE</version>
</dependency>
</dependencies>
...into my maven pom, which I did, but it fails to resolve the version.
So I looked and found this and I added a proxy repository to my nexus for the [release] (http://repo.spring.io/release) repository but still failed to locate the artifact.
Then I navigated to the http://repo.spring.io/release repo and manually searched and CANNOT FIND the artifact.
So, where I am going wrong?
That's a mistake in the guide.
Somewhere below it mentions "spring-context", so I believe that should have been:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.0.5.RELEASE</version>
</dependency>
Notice "spring-context" instead of "spring-framework".
Github issue to have that fixed: Github issue.

package com.felees.hbnpojogen.persistence does not exist

I cant find this package anywhere.
package com.felees.hbnpojogen.persistence does not exist.
Has anybody come across it?
The error came up when I tried to build a new CVS repository. In the pom.xml there is a dependency
<dependency>
<groupId>com.felees</groupId>
<artifactId>hbnpojogen</artifactId>
<version>1.4.4</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
.
You can download the package here

Categories

Resources