How to set Spring Classpath

2019-08-12 04:13发布

问题:

I am using IntelliJ and jus checked out working code from the svn.I am struggling to run the jar.

Its a simple core java Spring project.

Since I get the above error.I understand that the spring path is not set fine. How do I handle it.?

 private ApplicationContext appContext = new AnnotationConfigApplicationContext(ApplicationRepositoryConfiguration.class);

Application context file is a bean class here (@Bean annotation is used). I am not using a xml file.

回答1:

It seems like you are running your project from command line. Run following command :

java -classpath spring.jar;spring-sec.jar,......so on com.example.UrMainClass

while specifying jar in command, make sure you provide complete path of jar. Also check this link https://stackoverflow.com/a/10122038/1065180