I am creating a Spring Starter Project using Spring Tool Suite. I selected JPA, Web and Derby Database dependencies. When my new project is created the src folder displays a "?" mark as shown in the screenshot. What am I missing? Why the question mark?
Note that there's an entry called "Maven Dependencies" right above those folders. Maven doesn't download dependencies into your project, it puts them in your local repository (generally ~/.m2/repository).
The question marks have nothing to do with dependencies--they're Eclipse's indication that you haven't added those entries to source control. (Contrast with the mvnw and POM entries, which have a stylized disk pack to show they are in source control.)
Related
I am creating a maven project, in which I've two jar's for say x and y for now,which contains some helper classes for my project. I want to added these x and y jars to my project's pom.xml as dependency. As these two jar files are not available in maven repository. So I try to use these jar in my pom.xml with in repository tag.How to achieve this. I've searched in google and found one project , which is similar to my project.
when I build this it able to build application, I saw the jar file it created.But I couldn't create the same with new project. If I copy the entire pom.xml I'm able to build.What is dependency-reduced-pox.xml and how it will create. and in moven-local folder how it creates another pom.xml, which command is used to create these auto generated xml files Can any one help me to do this. Here are the screen shots of my maven project I got it .
here are other screen shot.
There are 3 ways:
A) Install your JARs to your local Maven repository and then use them in your project with provided groupId, artifactId and version: How to add local jar files to a Maven project? (this is quick & easy & pretty clean until you remove your local repository and delete your JARs accidentally).
B) Install Nexus or Artifactory (will will be then your remote Maven repository), set it up in your settings.xml, add those JARs to remove Maven repository and download them from there (this is much less error-prone, but in longer run it's worth it).
C) not recommended: Other response (btw. currently with most upvotes) from previously suggested resource: How to add local jar files to a Maven project? which contains systemPath tag. You shouldn't use it, because it will cause lots of headaches in the future (for example if you want to package your application to WAR), it's not the correct way, but it's possible.
In IntelliJ integrated with Tomcat maintaining a Maven project.
Occasionally the project structure changes and new JARs are being added and/or their versions keep changing, the changes are left out of the WEB-INF/lib.
In order to maintain a correct setup, I have to add them manually in the module structure to run Tomcat correctly. This happens a lot!
Can this be automated?
Manually adding missing JARs
EDIT:
After watching Eric Green's response I did some experimenting:
The project is a parent/child project with multiple poms in it's children.
After playing around with the pom.xml of the project and modifying the main <packaging>jar</packaging> to <packaging>war</packaging> I was able to make IntelliJ to automatically include everything it needs in WEB-INF/lib , I had to do more several modifications to fix the project but eventually this was the main issue. Otherwise I had to manually specify the needed dependencies in WEB-INF/lib.
Notice how the dropdown in the top toolbar in the image below has a Tomcat icon. This configuration automatically builds a standard web application, part of which of course being the placing of necessary dependencies into the WEB-INF/lib folder of the generated *.WAR archive (see the JARs inside WEB-INF/lib under the target directory in the image below). These were all placed there automatically by Maven during the "package" phase. See the steps at the bottom (below the screenshots) to ensure this occurs correctly.
Below is another screenshot showing the Run/Debug configuration for a Tomcat application. Maven is actually doing all the real work of assembling dependencies into a correct WAR archive, but IntelliJ is assisting in the management and deployment of the artifacts to the configured local Tomcat server.
So, to do this for yourself:
Set the packaging in your project's pom.xml file as "war"
Go to Run > Edit Configurations
Click the plus sign '+' and click Tomcat Server > Local
Fill in the dialog that pops up as directed
Run your Maven build ("clean install", or whatever you fancy)
Start Tomcat with your new Run/Debug configuration created in steps 3 and 4
I want to convert a Java/Dynamic web project to a Maven project. I use Eclipse IDE to develop Java applications.
One of the straight forward options available to me is to use 'Convert to Maven project' in Eclipse. But there are situations where I cannot use that option since the Maven plugin doesn't work in some networks like my Work environment.
So I want to know a Maven command (on Command Line) that would help me convert my Eclipse-built Java Web App to a Maven project.
Thank you in advance, Happy learning.
The Eclipse feature "Convert to Maven Project" works on projects that already have an appropriate POM. A project that was initially created by Eclipse doesn't have that POM.
So what you must do, is simply create a POM with packaging type WAR, then put it into the root of the project.
You also have to take care of the source directories. The Maven standard way is to have all sources under these four directories:
src/main/java
src/main/resources
src/test/java
src/test/resources
Eclipse simply stores everything under src. So you either change your file and directory structure, or you change the appropriate <build> parameters in the POM. I suggest the former.
The "Convert to Maven Project" feature does more than adding the Maven nature to the Eclipse build settings. It also creates and configures the Eclipse project meta files (the files .project and .classpath and the folder .settings). Therefore I suggest to delete them first in your project directory, so Eclipse can start on a clean project.
Afterwards you simply can convert your project with the above mentioned feature. It should create the meta files, and - as it is a web project (packaging type WAR) - it also should add the appropriate natures that let Eclipse show the project as a web project.
On a new computer, I pulled from source my intellij project (spring mvc), and when it opened up I got 10+ errors having to do with the maven modules not being setup correctly etc.
I noticed my appname.iml wasn't in m git repository.
I have this in my .gitignore:
*.iml
Should this file be included, or only this single appname.iml is required?
If you don't share .iml files, you also don't need to share .idea directory. In this case you will need to open pom.xml or use the new project wizard to import from Maven. Settings that are stored in IntelliJ IDEA project will have to be configured again on every machine.
If you choose to share IntelliJ IDEA project files (.idea directory and .iml), refer to the FAQ.
I have a Spring MVC web application where the majority of the code I am interested in sits in two Maven projects - one being the war project and another being a jar project on which the war depends. They also share the same parent pom though that is probably irrelevant for this question.
When I try to debug my web project I can't step into any of the code from the jar. I've checked Windows->Debugging->Sources and the jar project's source directory is present there. Both projects are open. Does Netbeans 7.0 not support stepping through a web project's dependencies?
In your library manager screen, in your sources tab, have you provided the location of the source folder.http://wiki.netbeans.org/AttachSourceToLibrary.
When you are stepping in to class files ( that netbeans could not find source far), there usually is a prompt from Netbeans asking if you want to associate a src with this corresponding file. Either way, I have managed to step into dependent projects using Netbeans.