这是我的Publisher对象:
import io.quarkus.hibernate.orm.panache.PanacheEntity;
import jakarta.persistence.Entity;
import java.time.Instant;
@Entity
public class Publisher extends PanacheEntity {
// ======================================
// = Attributes =
// ======================================
public String name;
public Instant createdDate = Instant.now();
// ======================================
// = Constructors =
// ======================================
public Publisher(String name) {
this.name = name;
}
public Publisher() {
}
@Override
public String toString() {
return "Publisher{" +
"name='" + name + '\'' +
", createdDate=" + createdDate +
", id=" + id +
'}';
}
}
这是我的测试:
import io.quarkus.test.TestTransaction;
import io.quarkus.test.junit.QuarkusTest;
import org.agoncal.quarkus.panache.model.Publisher;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@QuarkusTest
public class PublisherRepositoryTest {
@Test
@TestTransaction
public void shouldCreateAndFindPublisher() {
Publisher publisher = new Publisher("name");
publisher.persist(publisher);
assertNotNull(publisher.id);
publisher = publisher.findById(publisher.id);
assertEquals("name", publisher.name);
}
}
这是执行mvn clean install
时的错误:
-------------------------------------------------------------------------------
Test set: org.agoncal.quarkus.panache.repository.PublisherRepositoryTest
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 3.755 s <<< FAILURE! - in org.agoncal.quarkus.panache.repository.PublisherRepositoryTest
org.agoncal.quarkus.panache.repository.PublisherRepositoryTest.shouldCreateAndFindPublisher Time elapsed: 0.002 s <<< ERROR!
java.lang.RuntimeException: java.lang.NoClassDefFoundError: javax/inject/Provider
Caused by: java.lang.NoClassDefFoundError: javax/inject/Provider
Caused by: java.lang.ClassNotFoundException: javax.inject.Provider
我认为这个错误很奇怪,因为我在代码中没有使用javax。
1条答案
按热度按时间pdtvr36n1#
正如@geoand指出的那样,我将我的评论作为对未来读者的回答。
vintage-store
仍然使用Quarkus 2.x分支与其他项目使用Quarkus 3相反。