Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java spring error: It is not working even i đid exactly everything the teacher said

package springdemo4;

import org.springframework.context.support.ClassPathXmlApplicationContext;

public class HelloSpringApp {

    public static void main(String[] args) {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        Coach theCoach = context.getBean("myCoach",Coach.class);
        System.out.println(theCoach.getDailyFortune());
        System.out.println(theCoach.getDailyWorkout());
        context.close();

    }

}

I ran it, then it said:

Error occurred during initialization of boot layer java.lang.module.FindException: Unable to derive module descriptor for C:\Users\ngoch\eclipse-workspace\springdemo4\libs\spring-context-indexer-5.1.9.RELEASE-sources.jar Caused by: java.lang.module.InvalidModuleDescriptorException: Provider class org.springframework.context.index.processor.CandidateComponentsIndexer not in module

Please,help

like image 974
Bùi Ngọc Hà Avatar asked Aug 30 '19 23:08

Bùi Ngọc Hà


2 Answers

I had the same issue with Eclipse IDE. I mistakenly added the spring jar files under Modulepath. It should be under Classpath (Properties > Java Build Path > Classpath > addJARs ).

like image 98
Josue Nsumba Avatar answered Sep 22 '22 09:09

Josue Nsumba


You need to add the libraries under classpath and not under modulepath.

Eclipse IDE

like image 33
praveennin Avatar answered Sep 23 '22 09:09

praveennin