我正在使用Impinj高速公路连接器来连接RFID标签读取器;
如果我使用的是简单的核心Java程序,则将使用classpath中的辛烷SDK jar的外部jars来运行并运行该程序
但是当我将此程序转换为Spring Boot应用程序时,它将无法从jar中读取impinjReader类 impinjReader =新的ImpinjReader();
并一直给我NoClassDefFoundError
Spring boApplicationion
package com.Amazin.Tag.Reader;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import com.impinj.octane.ImpinjReader;
@SpringBootApplication
public class TagReaderApplication implements CommandLineRunner {
ImpinjReader impinjReader;
public static void main(String[] args) {
SpringApplication.run(TagReaderApplication.class, args);
}
@Override
public void run(String... args) throws Exception {
System.out.println("reading imping reader");
impinjReader= new ImpinjReader();
}
}
POM.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.Amazin.Tag.Reader</groupId>
<artifactId>Tag_Reader</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Tag_Reader</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.octane</groupId>
<artifactId>OctaneSDKJava</artifactId>
<version>1.28.0.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.0.2.RELEASE</version>
</dependency> -->
<dependency>
<groupId>org.llrp</groupId>
<artifactId>ltkjava</artifactId>
<version>1.0.0.6</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.15</version>
<exclusions>
<exclusion>
<groupId>com.sun.jmx</groupId>
<artifactId>jmxri</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jdmk</groupId>
<artifactId>jmxtools</artifactId>
</exclusion>
<exclusion>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
错误消息
java.lang.NoClassDefFoundError: org/apache/mina/core/RuntimeIoException
at com.Amazin.Tag.Reader.TagReaderApplication.run(TagReaderApplication.java:25) [classes/:na]
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:813) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:797) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:324) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at com.Amazin.Tag.Reader.TagReaderApplication.main(TagReaderApplication.java:17) [classes/:na]
Caused by: java.lang.ClassNotFoundException: org.apache.mina.core.RuntimeIoException
at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[na:1.8.0_191]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_191]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) ~[na:1.8.0_191]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_191]
... 7 common frames omitted