admin管理员组文章数量:1122832
I have a Spring Boot application where I am using System.loadLibrary() to load a native DLL for a receipt printer service. Everything works perfectly fine until I add spring-boot-devtools as a dependency to enable hot reloading. Once I add DevTools, the library fails to load, and my application encounters errors when trying to use the service. I get this error exception:
java.lang.UnsatisfiedLinkError: 'int net.jposprinter.printerio.IOPort.nativeOpenPort(int, byte[], int)'
Here’s a simplified version of my setup:
@Service
public class ReceiptPrinterService {
@Value("${dll.path}")
private String dllPath;
@PostConstruct
public void loadDll() {
try {
System.loadLibrary(dllPath);
} catch (UnsatisfiedLinkError e) {
System.out.println("Error loading DLL: " + e.getMessage());
e.printStackTrace();
}
}
public String printReceipt(String message) {
// Logic to interact with the receipt printer...
}
}
dependency added:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
I tried adding this to application.properties:
spring.devtools.restart.exclude=resources/libs/**,resources/jpos.xml
but still didn't work (the dll is in libs directory)
What I Need:
Why does adding Spring DevTools interfere with loading native DLLs?
What is the best way to configure Spring DevTools to avoid this issue while keeping the hot reload functionality for the rest of the application?
Are there alternative approaches to loading the native library in a way that avoids these conflicts?
Any help or insight would be greatly appreciated. Thanks in advance!
本文标签:
版权声明:本文标题:java - Why does adding Spring DevTools cause issues with loading native DLLs in my Spring Boot application? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736310665a1934460.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论