component-scan not working on jar file - java

springmvc-context.xml configuration file
Jar is placed in WEB-INF/lib.
Its giving 404 while trying to access the controller. How to find out its being initiating or not even and further work.

Try to place:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
</dependency>
this dependency in pom.xml file for the spring-context jars.
But before this have you placed your jar file from WEB-INF/lib to the build path. If not the first place the jar in the build path of the project.
This might help. Thanks!!!

Related

How to add local jars folder in class path using POM

There are almost 10 local jars (these jars are required to build my application) in my Java application. I want them to add to the classpath using POM. How can I do that?
You can add the dependency as system scope and refer to it by its full path. Consider that the JAR is located in /lib. Then add the dependency in your pom.xml file as following:
<dependency>
<groupId>com.abc.pqr</groupId>
<artifactId>sample-app</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${basedir}/lib/your_jar.jar</systemPath>
</dependency>
${basedir} represents the directory containing pom.xml.

A pom.xml inside jar in META-INF\maven\ is not getting afect

i have added a dependency in my pom.xml like:
<dependency>
<groupId>com.excample</groupId>
<artifactId>someJar</artifactId>
<version>${version}</version>
</dependency>
inside that jar, in META-INF\maven\com.excample\someJar\ dir, there is another pom.xml.
when i run mvn clean install all its dependencies not getting downloaded or added to classpath.
Is there any reason for that?
Thanks in advance.

No files were downloaded for org.springframework:org.springframework.core:3.2.2.RELEASE

I created a small java application using intellij, later I updated that project as Maven project using "Add framework support" option. When I tired to add spring jar file on project I got following error saying,"No files were downloaded for org.springframework:org.springframework.core:3.2.2.RELEASE".
Following are the steps I did to add spring jar files
1)Clicked on File -> Project Structure -> Modules -> Clicked on "+" Sign -> Library -> From Maven
2)Searched for org.springframework.core and selected 3.2.2 Release
3)Downloaded to lib folder under my project.
4)Got Error.
I don't know where it went wrong. I am new to java and spring application.
As already mentioned, Maven downloads dependencies itself (a reason why it's a build automation tool).
To add Spring as a dependency, add this code to Maven's pom.xml (the file is in your module's root directory):
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.2.2.RELEASE</version>
</dependency>
</dependencies>
Also, delete the lib directory from your project root - Maven doesn't put jars there.
Maven downloads the dependencies automatically, can you try adding this to the pom.xml file. Maven should automatically download the dependencies..
<!-- https://mvnrepository.com/artifact/org.springframework/spring-core -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.2.2.RELEASE</version>
</dependency>

Specific spring-core jar to be included in project

Ive included following lines in my pom.xml
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.1.6.RELEASE</version>
</dependency>
The specific spring-core JAR version I want is 4.1.6, but whenever I do an mvn clean install, the dependencies folder under my project in netbeans shows a downgraded version (currently 3.0.7.RELEASE).
I want to know how I can force maven to put 4.1.6.RELEASE jar in my dependencies folder. I've done
mvn dependency:purge-local-repository -DactTransitively=false -DreResolve=false
And I've the folder 4.1.6.RELEASE with correct jar in my local /.m2/repositories folder. I need to access org.springframework.util.MimeType class which is not available in spring-core 3.0.7.RELEASE jar.
See the result of mvn dependency:tree to know if another jar bring back the version 3.0.7. and exclude from this dependency the spring-core
See the same result to know if the right version is present
Add the pom.xml and the result of mvn dependency:tree in the question
Please follow these steps:
Check in .m2 local repository where the Spring 3.0.7 jar is downloaded(It should be under folder org->springframework)
Delete the folder present inside springframework, so that mvn will try to fetch required dependencies.
Let me know if it helps
The issue is that spring-core is a mandatory dependenecy of most spring artifacts. Most likely you are using a dependent artifact e.g spring-context which is of version 3.0.7. Then Maven is fetching spring-core of the same version as the dependent artifact using its transitive dependency mechanism.
To control the version of spring-core you need to move its declaration from the dependencies section to the dependency management section of your pom.xml as follows
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.1.6</version>
</dependency>
</dependencies>
</dependencyManagement>

Errors in maven Struts2 project

Eclipse displays errors in a Maven project. How can I fix it?
It seems that project works as it should.
Maven dependencies:
<dependency>
<groupId>com.jgeppert.struts2.jquery</groupId>
<artifactId>struts2-jquery-plugin</artifactId>
<version>3.7.1</version>
</dependency>
<dependency>
<groupId>com.jgeppert.struts2.jquery</groupId>
<artifactId>struts2-jquery-grid-plugin</artifactId>
<version>3.7.1</version>
</dependency>
The jars downloaded from these artifacts should be on the classpath of the project Build Path. Subfolders aren't on the classpath, so eclipse can't find TLDs there. Configure the build path by adding project or external jars to the build classpath. You can see How to generate eclipse configuration from maven project.
Try /struts2-jquery-tags instead of /struts-jquery-tags. Missed the '2' in struts.

Categories

Resources