构建本地quarkus图像时出现问题,尝试使用mongo panache查询。 如果我使用开发人员配置文件或构建普通的jar,则一切正常。
这是我的Dockerfile.native
query = """SELECT stuff FROM TABLE WHERE name LIKE '%%(this_name)s%'"""
results = pd.read_sql(query, con=cnx, params={'this_name': some_name})
## Stage 1 : build with maven builder image with native capabilities
FROM quay.io/quarkus/centos-quarkus-maven:19.2.1 AS build
COPY backend /usr/src/app/backend
COPY frontend /usr/src/app/frontend
COPY pom.xml /usr/src/app/
USER root
RUN chown -R quarkus /usr/src/app
USER quarkus
RUN cd /usr/src/app/ && mvn clean package -Pnative -Dnative-image.xmx=4g
RUN mkdir -p /tmp/ssl-libs/lib \
&& cp /opt/graalvm/jre/lib/security/cacerts /tmp/ssl-libs \
&& cp /opt/graalvm/jre/lib/amd64/libsunec.so /tmp/ssl-libs/lib/
## Stage 2 : create the docker final image
FROM registry.access.redhat.com/ubi8/ubi-minimal
WORKDIR /work/
COPY --from=build /usr/src/app/backend/target/*-runner /work/application
COPY --from=build /tmp/ssl-libs/ /work/
RUN chmod 775 /work
EXPOSE 8080
CMD ["./application", "-Dquarkus.http.host=0.0.0.0", "-Djava.library.path=/work/lib", "-Djavax.net.ssl.trustStore=/work/cacerts"]
有人有类似的问题吗?
编辑
域(域和类别也具有默认的委托人)
ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (vert.x-worker-thread-1) HTTP Request to /api/budget failed, error id: 86ff4366-b0d2-49c5-87f7-e6eee9d71feb-1: org.jboss.resteasy.spi.UnhandledException: org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class domain.Budget.
at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:106)
存储库
@MongoEntity(collection = "Budget")
public class Budget {
private ObjectId id;
private Period period;
private List<Category> categories;
public Budget() {
period = new Period();
categories = new ArrayList<>();
}
//business method getter setters...
}
控制器
@ApplicationScoped
public class BudgetRepository implements PanacheMongoRepository<Budget> {
}
答案 0 :(得分:0)
GraalVM本机映像需要知道需要通过关联才能访问的类。由于您的REST端点使用Response
返回类型,因此Quarkus无法自动获取Budget
类的反射,因此您需要为此使用@RegisterFroReflection
批注。
有一个PR可以为您完成任务,因此您很快将不再需要自己做:https://github.com/quarkusio/quarkus/pull/6326/files
但是只要不合并,就需要在@RegisterFroReflection
类上添加Budget
注释。