Build failure in Spring-boot-starter project due to missing WebApp libraries - eclipse

I have a Spring-Boot-Starter-project in Eclipse Oxygen 4.7.0 and is trying to build a .war for deployment on an EC2 instance. I have added two jars to allow JDBC connectivity to PostgresSQL DB server from my deployed war.
I have also added the src/main/webapp/WEB-INF/lib path to the project build path as shown below
However, I am getting the Compilation error when I am doing mvn compile with a build failure stating the reason as unavailability of the jar classes
Any help will be really appreciated

You have configured Project build path in your eclipse, and it will not impact anything when you are doing mvn compile. Maven will not include the jar from the lib folder as it does not know lib folder's presence. You should apply either of below two options:
a. If those jars are present in maven repository then update your pom to read from maven repository directly.
b. Install these jars in your local repository then refer it in your pom.xml, check https://stackoverflow.com/a/30209982/3530898 for details

Related

Created a maven project with jersey archtype but fail to build due to missing jersery servlet library

I m trying to create a maven project with the jersey archtype by following the tutorial below.
https://www.youtube.com/watch?v=skltzZH7i4w&list=PLqq-6Pq4lTTZh5U8RbdXq0WaYvZBz2rbn&index=11
The maven project fails to build with a number of errors. The root cause, I believe, is this one:
The container 'Maven Dependencies' references non existing library 'C:\Users\XXXXXXXX.m2\repository\com\sun\jersey\jersey-servlet\1.20-SNAPSHOT\jersey-servlet-1.20-SNAPSHOT.jar'
The jar doesn't exist, in fact the \jersey... folder is missing. I am using eclipse, and have installed m2e. What else do I need to bring the jersey dependent files onto the computer?
I repeated the same steps on my home computer and was able to get thru. I suspect the root cause was network/firewall setting at my work.

Making Eclipse Maven repository inside the project

I'm a real beginner to Maven and Spring framework in eclipse so excuse me if this sounds trivial..
I have created a MVC web project in eclipse using the STS plugin on my windows computer, but my problem is that the location of the jar and configuration files that maven is set to by default is: C:\Users\MyName.m2\repository
This is a problem for me because eventually I'm going to make a WAR file out of my project and deploy it on a Linux machine, which does not have Maven installed on it.
My question is, is it possible to take all the jar files in my Maven repository, and make a local repository on the project itself rather than on an absolute path on the machine (sort of like a lib folder within the WEB-INF in the project that will hold all the maven jars and that maven will direct itself to it), and thus making the transition to the Linux machine smooth
I understand there is this classpath variable named M2_REPO, but doesn't seem to be editable or accept relative path rather than absolute.
Thanks in advance
Since you are using maven and you are adding your dependencies on your pom.xml, then all the dependencies with a scope of "compile" will be added to your final war file created by the maven war plugin under the WEB-INF/lib folder, this means that you should not worried about having maven in your linux server, since the war file that you are going to deploy will contain all the necessary dependencies. If you want to confirm this, just create a package of your project using "mvn clean package" and check the "target" folder generated by maven, you will see a "war" file, and you can unzip your file to check what contains.

Where do Maven look for springMVC jars when working with eclipse(maven plugin installed)

I am using m2e plugin.
Just stuck at one point when maven search for springMVC jar files where it would be searching.
In /web-inf/lib or in project build path.
Where should I put those jars
Thanks
Maven looks for jars in its repositories.
Therefore you don't need download jars manually when using Maven, it will automatically download jars from remote repository and put it to the local repository on your machine.
Maven uses "settings.xml" file to find out your project repositories. and resolve dependencies(every jar files that you need) from those repositories.
more about seetings.xml and also
this one .
After downloading required jar file for first time, maven puts it in your local repository in:
${user-home}/.m2/repository.

Local Project Dependencies and Maven

I'm converting an ant backed Netbeans project into an Maven project. I've got most of the third party libraries set up in the POM, however now I've run into problems with setting up the local dependencies.
With the previous Netbeans way of doing things, it just added a project reference [with links to the source and jar location, rebuilt the dependency if the depedency's source had been changed and hadn't been compiled]. However I'm not sure how to setup up Maven to emulate this behavior. Is it possible?
Example:
Projects/SharedLibrariesResource [Ant based project]
Projects/WebSite [this is a maven based project]
Projects/Client
In this example the website and client projects don't connect to each other, but they do share the SharedLibrariesResource. Website should compile to produce a War with links to the SharedLibrariesResource
The way I understand the question, the Website maven project depends on the ant SharedLibrariesResource project. When Website is built, it should include the SharedLibrariesResource artifacts. The assumption is SharedLibrariesResources produces a jar artifact.
One way to achieve this is to
install SharedLibrariesResource to your local maven repository each time ant builds it
specify this as a dependency in Website pom.
We can use maven ant tasks to achieve the first.

ClassNotFoundException when using User Libraries in Eclipse build path

I'm using Eclipse 3.7 (STS) with Tomcat 7 running inside the IDE. I've created a new Dynamic Web project and added a single JSP file to the web content root folder. I can run Tomcat and access the JSP from within Eclipse with no problems.
I've added a few 3rd party JAR's to the project from User Libraries (I'm not using maven or auto dependecies managment). In the JSP I reference a class from the project's JAR file, I can compile this with no problem, but when I deploy on Tomcat the JSP throws ClassNotFoundException. Clearly, Tomcat can't find the JAR's from my library settings. I tried creating a Run As configuration for Tomcat Server and I set the classpath to match the classpath settings of the project, but I still get the same classnotfound problem.
I could get around the issue by manually copying all project JARs to the WEB-INF/lib directory so the webapp can find all dependencies, but that's absurd and I don't expect that to be the solution since it's a maintenance nightmare.
Am I missing something?
In project's properties, go to Deployment Assembly. Add there the buildpath entries as well which you've manually added as user libraries. It'll end up in /WEB-INF/lib of the deployed WAR.
You'll need to copy the jar files to the WEB-INF/lib folder: that is where they are supposed to be.
Eclipse should offer you the option of generating a WAR file that includes all the dependencies: I haven't used Web Tools for a good while but one way or another all dependencies have to be in WEB-INF/lib or the class loader won't be able to find them.