我有一个带有一些初始化的spring boot应用程序,但是它们依赖* .so,现在我在初始化时对System.loadLibrary("cstaapi")
做@Configuration
,但例外:
20180628 19:58:32,387错误[主要] [org.springframework.boot.SpringApplication]应用程序启动 失败的java.lang.UnsatisfiedLinkError:com.xxx.module_init()V
我找不到原因?
代码:
@Configuration
public class LibLoader {
static {
System.out.println("==========LibLoader Configuration===========");
System.loadLibrary("sntsapi");
}
}
@SpringBootApplication
@EnableEurekaClient
@EnableFeignClients
@ComponentScan(value = {"cn.xxx.*"})
@EntityScan("cn.xxx.*")
@EnableScheduling
public class CstaServiceApplication {
public static void main(String[] args) {
System.out.println("=== java.library.path ===" + System.getProperty("java.library.path"));
SpringApplication springApplication = new SpringApplication(CstaServiceApplication.class);
springApplication.addListeners(new GlobalInit());
springApplication.run(args);
}
}
public class GlobalInit implements ApplicationListener<ContextRefreshedEvent>
{
@Override
public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
System.out.println("======== GlobalInit ========");
GlobalInitManager.getInstance().doInit();
}
}
@Configuration
public class LibLoader {
static {
System.out.println("==========LibLoader Configuration===========");
System.loadLibrary("sntsapi");
}
例外:
20180628 19:58:32,380 INFO [main] [org.springframework.boot.autoconfigure.logging.AutoConfigurationReportLoggingInitializer]
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
20180628 19:58:32,387 ERROR [main] [org.springframework.boot.SpringApplication] Application startup failed
java.lang.UnsatisfiedLinkError: com.xxx.module_init()V
at com.xxx.apiJNI.module_init(Native Method) ~[csta.jar:?]
at com.xxx.apiJNI.<clinit>(sntsapiJNI.java:2039) ~[csta.jar:?]
at com.xxx.apiJNI.ACSHandle_t_4j.<init>(ACSHandle_t_4j.java:47) ~[csta.jar:?]
at cn.xxx.CstaSession.<init>(CstaSession.java:49) ~[CstaService.jar:?]
at cn.xxx.doInit(CstaSessionManager.java:49) ~[CstaService.jar:?]
at cn.xxx.doInit(GlobalInitManager.java:54) ~[CstaService.jar:?]
at cn.xxx.onApplicationEvent(GlobalInit.java:16) ~[CstaService.jar:?]
at cnxxx.onApplicationEvent(GlobalInit.java:10) ~[CstaService.jar:?]
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:393) ~[spring-context-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:347) ~[spring-context-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:883) ~[spring-context-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:144) ~[spring-boot-1.5.10.RELEASE.jar:1.5.10.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546) ~[spring-context-4.3.14.RELEASE.jar:4.3.14.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.10.RELEASE.jar:1.5.10.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.10.RELEASE.jar:1.5.10.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.10.RELEASE.jar:1.5.10.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.10.RELEASE.jar:1.5.10.RELEASE]
at cn.xxx.CstaServiceApplication.main(CstaServiceApplication.java:34) [CstaService.jar:?]
20180628 19:58:32,394 INFO [main] [org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext] Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@b12f8a: startup date [Thu Jun 28 19:58:28 CST 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@15b810e
20180628 19:58:32,395 INFO [main] [org.springframework.cloud.netflix.eureka.serviceregistry.EurekaServiceRegistry] Unregistering application csta-service with eureka with status DOWN