I have been stuck in the problem for quite a while.I use Intellij and maven not very long.
the problem like this:
the version of my Intellij is 12.1.4,I am making a project of Spring MVC with maven.So the output directory is 'target' in the project workspace.I have a mybatis xml file in my path.
once I found that the xml file did not change autoautomaticly in the target directory.so I delete it in the target directory.after I have done this,I rebuild the project,but the file never appear any more.
why?how should I do?
put that file in src/main/resources, maven copies all the resources from default resource directory to target/classes
Related
I want to run a liquibase update by the liquibase-maven-plugin, but the changeset yml file is inside a .jar that I pull in by dependency.
When I open the .jar with TotalCommander, it has the following structure:
xy.jar/changelog/changeset.yml.
I tried including it as a resource directory, but it failed telling me the .jar is not a directory.
I also tried building to a WAR and just setting the liquibase changeLogFile property to the path leading to the .jar, like {projectDir}/target/..war/..lib/..jar/changelog/myFile.yml
But maven could not find it this way.
Is it possible to access this file somehow?
You can read the file using below code.
InputStream inputStream = getClass().getClassLoader().getResourceAsStream("changelog/myFile.yml");
Thanks for the reply, but the solution was simpler, I'm just rusty in this area :) I simply had to add the required JAR from the WAR as a Maven Dependency. This adds the JAR's content to the classpath in the Maven build process, so I can reference to it's files as they were on the project root path.
TLDR: add JAR as dependency in the pom and use the path:
<changeLogFile>changelog/xy.jar</changeLogFile>
I'm using eclipse and ant to compile a java project. The ant compile script calls javac using a classpath refid of classpath, which is set based on System Property variable java.build.path.
My java.build.path variable is missing a library that was specified in
Project->Properties->Java Build Path->Libraries.
That is, the external jar was properly added to the list of libraries to add to the build path, is not missing or corrupt, and I have every expectation that eclipse would include the library in the build path. My build fails because java.build.path is missing this library.
Furthermore, the file <projectDir>/.classpath contains a valid classpathentry element for the missing jar file.
When building, javac fails at an import statement, claiming that the package does not exist. The value of java.build.classpath contains many of the libraries I set in the project properties, but does not include the missing library. Its as if the project property for that external jar was never set.
For what its worth, the missing library is jboss/lib/jbosssx.jar
Any help here would be appreciated.
At first,
Download jbosssx.jar jar file from this link
Then keep the jar file in the folder jboss/lib
Hope it will solve your issue.
UPDATE:
Sometimes jar files need to keep in lib folder physically. For this reason, you can put the jar file in your project lib folder.
I found where my configuration was messed up.
Using External Tools Configurations within eclipse, I found another Classpath settings tab for my ant build that did not contain my library.
Adding my library here caused the build to succeed!
Skywalker, thanks for the suggestion. :)
I created my first maven project and I get Java build path problem in it.
Description Resource Path Location Type
Archive for required library: 'C:/Users/simran/.m2/repository/org/glassfish/extras/glassfish-embedded-web/3.1.1/glassfish-embedded-web-3.1.1.jar' in project 'RestfulMessenger' cannot be read or is not a valid ZIP file RestfulMessenger Build path Build Path Problem
This jar is present in the location mentioned, I tried deleteing it from there , cleaning the project and updating the maven but nothing fixed the error.
What seems wrong?
You should try doing
Maven -> Update Project and make sure you check Force Update of Snapshots/Releases
Deleting the corresponding .jar files from local repository and reissuing the maven command did the trick. It seems the .jar files got corrupted while downloading.
I have a Java maven project where I need to use logback as the logging framework. I have placed the logback.xml configuration file in the src/main/conf folder. However, it looks like it is not getting picked up because src/main/conf is not in the class path. On building the project I copy all the contents of that folder to target/root/conf and wanted to have that directory as part of my classpath. Can anyone let me know how can I force that?
In a Maven project the default directory for resource file is src/main/resources. This is the layout directory,
if you still want to change this default, follow these instructions.
I don't want to put my .properties and log4j files in my /resources folder in my spring MVC appication because these will get put into the jar at compile time, and I want to be able to edit these files on my server when I deploy my application.
So I created a folder and dropped my log4j, *.properties files, and my spring-context.xml file in it.
I have a maven multi project, and my folders look like:
/myapp-persists
/myapp-web
/src/main/conf
The /src/main/conf has my property files, so in IntelliJ I went to the myapp-web module and added a 'jar or directories' dependancy, pointed to that folder and chose 'classes'.
It didn't work, my files were not picked up and starting the server resulted in a crash, the property files were not detected.
What am I doing wrong here?
It seems me doing this via intelliJ is going to cause my maven builds to fail then right? I really don't want to create a separate maven project for this.
You can just use the context menu on /src/main/conf and choose Directory : Add as Source. In the preferences you should set keep source folders in the maven settings (not really sure about the naming of the menu/settings - no idea at hand, sorry). The jar dependency is not needed.