Too many Maven dependencies

I’m trying to configure the simplest simple applications for sleep mode, and for reasons beyond my mediocre thinking, I can’t get it to work. Maven is quite simple - adding dependencies to the build path, updating the project, blah blah blah bha-yadda-yadda-poison

It started as one ClassNotFoundException , which required a missing dependency. I would import the missing jar and run the application again, just to get another ClassNotFoundException . The next thing I know, I have a TONE OF JORES AND NO WORKING APPLICATION

enter image description here

* Directories have been disguised to protect the failed

I used Maven and Hibernate in my last project at Eclipse Kepler, and it was too easy, ha! Updating Luna was a real pain when trying to get Maven to work correctly - disabling the Java Compilier compliance level to be able to update the dynamic web module, not to mention manually creating missing src / main / java and src / test / java folders standard with maven-archetype-webapp , the list maven-archetype-webapp on. I spent a lot of time not to finish the job.

In my last project, all I needed to import was:

 <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1.0</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>4.3.6.Final</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-c3p0</artifactId> <version>4.3.6.Final</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>4.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>4.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>4.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.codehaus.jackson</groupId> <artifactId>jackson-mapper-asl</artifactId> <version>1.9.13</version> </dependency> 

That's all! I swam in session factories and updated the database tables as if it were my job (this is so).

It makes me think that some basic functions are missing in this new project. I might have missed something in updating the IDE. It can almost guarantee its way to build. Please, help!

About my project - I use: Eclipse Luna (Kepler was 100 times easier to configure with Maven) Maven Webapp JDK-1.7 archetype Hibernate Core 4-3.6

My last exception was

  Exception in thread "main" java.lang.NoClassDefFoundError: javax/persistence/NamedStoredProcedureQuery at org.hibernate.cfg.AnnotationBinder.bindDefaults(AnnotationBinder.java:276) at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1402) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1844) at com.boa.ecris.test.Main.main(Main.java:22) Caused by: java.lang.ClassNotFoundException: javax.persistence.NamedStoredProcedureQuery at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) ... 4 more 

If this is specific to javax persistence-api.jar , it is already there !!!

+5
source share
3 answers

Java APIs change over time. You need to find the correct version of your dependency (namely the one that contains the version of the API you want / should use). Since you told Maven to use version 1.0.2 persistance-api , you can know what Maven will do better.

If the error persists, then the next step should be the central Maven repo, in particular the "find for me" search dialog: http://search.maven.org/#search%7Cga%7C1%7Cfc%3Ajavax.persistence. NamedStoredProcedureQuery

Then you need to understand what dependencies you want in your project and choose the right one from the list. Since Maven is not aware of your limitations, this is what you need to find out.

A word of wisdom: a computer does not have a brain, brings its own.

+2
source

When you have a ClassNotFoundException , first of all, you should look at your repository site. You can get the maven repository URL from the settings file in the .m2 folder. Then you can search for your dependency on this site using the id and version artifact . If your version is not there, you can see another version and place it in your place. Thus, you can ensure stability in your project without adding manually.

0
source

Luna can also create a hierarchy of maven projects. In the "New maven project" dialog box, select the Create a simple project check box (skip archetype selection) .

0
source

Source: https://habr.com/ru/post/1202293/


All Articles