I've created a little test app as a console program in java that tries to work with hibernate, and I'm trying to connect to an instance of SQL-Server-2008. But when I run my app I'm getting an error stating that it can't find the JDBC driver.
Now I've created the project as a maven project so if the driver is available as a maven dependency that would be great, although I couldn't find it. I do however have the actual .jar file, but I have no idea where to put this in my project structure. Which look like this:
So.. any help would greatly be appreciated! Thanks :)
Download it from http://msdn.microsoft.com/en-us/sqlserver/aa937724 and then install
mvn install:install-file -Dfile=sqljdbc4.jar -DgroupId=com.microsoft.sqlserver -DartifactId=sqljdbc4 -Dversion=3.0 -Dpackaging=jar
Once you include it using maven, it is referenced from maven directory.
Related
I want to use ws4j for my project. And i can't able to connect to the internet all the time. So, most of time i download dependency to local repository using dependency:get command. Then i use it in project.
like that i tried download ws4j-1.0.1. But i get a error while downloading. It says Missing POM for edu.cmu.lti:ws4j:jar:1.0.1. But there is a pom file in the repository. see the url ws4j repository. But why i get the error.
The command i used was mvn dependency:get -Dartifact=edu.cmu.lti:ws4j:1.0.1
The image of the error i get
I am using maven version 3.6.3
Please, someone help to solve this issue.
mvn dependency:get -Dartifact=edu.cmu.lti:ws4j:1.0.1
This tries to download the dependency from https://repo.maven.apache.org/maven2/ and since it does not find the dependency there, it fails.
You need to specify "-DremoteRepositories" to fetch it from a remote repository.
For example: mvn dependency:get -Dartifact=org.apache.maven:maven-core:2.2.1:jar:sources -DremoteRepositories=https://repo.maven.apache.org/maven2 -Ddest=/tmp/myfile.jar
Please refer https://maven.apache.org/plugins/maven-dependency-plugin/usage.html
I'am trying to import a class but the Eclipse doesn't recognize the downloaded libraries. I have tried to Update my Maven's project via Maven-> Update Project it did not help. I tried to remove all dependencies except selenium-java and it did not help as well as redownloading the project from repository after a maven project update. Please need a hand, have no ideas what else should i do?
P.S. I tried to download the project on another machine and for first it didn't work but after a second attempt it went well and compiled.
Screenshot of the error:
Try inspecting /org/seleniumhq/selenium/selenium-firefox-driver/3.8.1/selenium-firefox-driver-3.8.1.jar in your local Maven repository. Perhaps it's corrupted.
You can also try building the project from command line. Simple mvn clean install in command line should print the same error as you get in Eclipse. This will confirm that you don't have problems with your Eclipse setup.
1 . Check the Build path if it looks like image
Or 2. if you can not see the highlighted class as
In this case re download the selenium jar or download another build
I'm an inexperienced docker user and I'm trying to dockerize my maven web application using Oracle. When I try to build using my maven image it fails saying: "Could not find artifact com.oracle:ojdbc14:jar:10.2.0.4.0 in central" which is expected since I have not included the driver anywhere.
My question is how can I make docker aware of the driver's location and thereby be able to build the app? Thanks
When I try to build using my maven image it fails saying: "Could not find artifact com.oracle:ojdbc14:jar:10.2.0.4.0 in central" which is expected since I have not included the driver anywhere.
You would need to reproduce in your Dockerfile the same setup (same M2_HOME, sans m2/repository settings) as the one which is working on your host (without docker)
You could start your Dockerfile from a maven image, or, as in this Dockerfile, from a jdk image, installing maven yourself, and deploying your missing jar the same way you would on your host.
I am developing a project based on java and mongodb. MongoDb is my backend, but when I try to connect it, says
[ERROR] /var/lib/openshift/someclass.java: error: cannot find symbol
[ERROR] package com.mongodb
I know this is a problem in Maven build as it cant find the methods and classes in my DBconnect class.
Please tell me how to solve the problem. I need to figure out as soon as possible. How to include my jar in maven repo and upload to openshift.
Double check that your dependencies are listed correctly in your pom.xml
If you can't or don't want to add the dependency to your pom.xml file, try following this KB article about how to add the jar file to your project: https://www.openshift.com/kb/kb-e1087-how-to-include-libraries-jar-files-in-your-java-application-without-using-maven
I am playing to Maven and tried to built a simple HellowWorld application.
This application uses Spring to libraries.
When I tried to run it, I run it through:
\target\classes
with command:
java -cp HelloWorldApp
It has a long list of classpath dependencies.
I think maven must have some more clever ways to do this instead of listing a whole list of dependency libs.
Can someone help?
Update:
Thanks. I now have another question. I run the project using:
mvn exec:java -Dexec.mainClass="com.vaannila.HelloWorldApp"
However, my project uses a Spring config called beans.xml which is in the
\src\main\resources
When I run it, it says:
Caused by: java.io.FileNotFoundException: class path resource [beans.xml] cannot be opened because it does not exist at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:142)at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.jav
a:336)
How can I specify where to look the Spring config?
Many thanks
Run your application by issuing mvn exec:java at the command line, maven will take care of the rest including download of the maven exec plugin.
EDIT As for your updated question: It appears that maven did not copy your resources to the target folder, you can use the maven-resources-plugin to do that. This link should help you get this done.
If you use IDE, such as eclipse +m2eclipse - it will calculate all dependencies from maven dependencies.
If you are running from command line use Exec maven plugin