为什么 Hibernate Search 需要花费这么多时间来构建索引?

2024-01-01

我正在尝试通过 hibernate 搜索构建 lucene 索引FullTextSession.createIndexer().startAndWait()但即使测试数据非常少,它也不会结束。

这是我的代码

@Component("hibernateSearchMassIndexerService")
public class HibernateSearchMassIndexerServiceImpl implements HibernateSearchMassIndexerService {

    public static final Logger log = LoggerFactory
            .getLogger(HibernateSearchMassIndexerServiceImpl.class);

    @Override
    @Transactional
    public void buildSearchIndex(Session session) {
        log.debug("Indexing entities");

        FullTextSession fullTextSession = Search.getFullTextSession(session);

        try {
            fullTextSession.createIndexer().startAndWait();
        } catch (InterruptedException e) {
            log.debug("Interrupted indexing process");
        }

        log.debug("Ended indexing of entities");

    }

}

Entities

@Entity
@Indexed(index = "causa_penal")
@Table(name = "causas_penales")
public class CausaPenal implements Serializable {

    private static final long serialVersionUID = 1L;

    @Basic
    @Column(name = "anio_causa")
    @Field
    private Integer annioCausa;

    @OneToMany(mappedBy = "causaPenal")
    @ContainedIn
    @OrderBy
    private List<AudienciaOral> audienciasOrales;

    @ManyToMany(cascade = CascadeType.ALL)
    private List<DefensorPenal> defensoresPenales;

    @OneToMany(cascade = CascadeType.ALL)
    private List<DelitoConfigurado> delitosConfigurados;

    @Id
    @GeneratedValue(strategy = GenerationType.TABLE)
    @Column(name = "id")
    @DocumentId
    private Integer id;

    @ManyToMany(cascade = CascadeType.ALL)
    @JoinTable(name = "causapenal_imputados")
    @IndexedEmbedded(depth = 1)
    private List<ParteMaterial> imputados;

    @ManyToMany(cascade = CascadeType.ALL)
    private List<MinisterioPublico> ministeriosPublicos;

    @Basic
    @Column(name = "numero_causa")
    @Field
    private Integer numeroCausa;

    @Version
    @Column(name = "opt_lock")
    private Integer version;

    @ManyToMany(cascade = CascadeType.ALL)
    @JoinTable(name = "causapenal_victimas")
    @IndexedEmbedded(depth = 1)
    private List<ParteMaterial> victimas;

    public CausaPenal() {
    }

    public CausaPenal(Integer id, Integer version, Integer numeroCausa, Integer annioCausa,
            List<DelitoConfigurado> delitosConfigurados, List<ParteMaterial> victimas,
            List<ParteMaterial> imputados, List<MinisterioPublico> ministeriosPublicos,
            List<DefensorPenal> defensoresPenales, List<AudienciaOral> audienciasOrales) {
        super();
        this.id = id;
        this.version = version;
        this.numeroCausa = numeroCausa;
        this.annioCausa = annioCausa;
        this.delitosConfigurados = delitosConfigurados;
        this.victimas = victimas;
        this.imputados = imputados;
        this.ministeriosPublicos = ministeriosPublicos;
        this.defensoresPenales = defensoresPenales;
        this.audienciasOrales = audienciasOrales;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (obj == this) {
            return true;
        }
        if (!(obj instanceof CausaPenal)) {
            return false;
        }

        CausaPenal o = (CausaPenal) obj;

        return new EqualsBuilder().append(this.numeroCausa, o.numeroCausa)
                .append(this.annioCausa, o.annioCausa).isEquals();

    }

    public Integer getAnnioCausa() {
        return this.annioCausa;
    }

    public List<AudienciaOral> getAudienciasOrales() {
        return this.audienciasOrales;
    }

    public List<DefensorPenal> getDefensoresPenales() {
        return this.defensoresPenales;
    }

    public List<DelitoConfigurado> getDelitosConfigurados() {
        return this.delitosConfigurados;
    }

    public Integer getId() {
        return this.id;
    }

    public List<ParteMaterial> getImputados() {
        return this.imputados;
    }

    public List<MinisterioPublico> getMinisteriosPublicos() {
        return this.ministeriosPublicos;
    }

    public Integer getNumeroCausa() {
        return this.numeroCausa;
    }

    public Integer getVersion() {
        return this.version;
    }

    public List<ParteMaterial> getVictimas() {
        return this.victimas;
    }

    @Override
    public int hashCode() {

        return new HashCodeBuilder(13, 33).append(this.numeroCausa).append(this.annioCausa)
                .toHashCode();
    }

    public void setAnnioCausa(Integer annioCausa) {
        this.annioCausa = annioCausa;
    }

    public void setAudienciasOrales(List<AudienciaOral> audienciasOrales) {
        this.audienciasOrales = audienciasOrales;
    }

    public void setDefensoresPenales(List<DefensorPenal> defensoresPenales) {
        this.defensoresPenales = defensoresPenales;
    }

    public void setDelitosConfigurados(List<DelitoConfigurado> delitosConfigurados) {
        this.delitosConfigurados = delitosConfigurados;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public void setImputados(List<ParteMaterial> imputados) {
        this.imputados = imputados;
    }

    public void setMinisteriosPublicos(List<MinisterioPublico> ministeriosPublicos) {
        this.ministeriosPublicos = ministeriosPublicos;
    }

    public void setNumeroCausa(Integer numeroCausa) {
        this.numeroCausa = numeroCausa;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }

    public void setVictimas(List<ParteMaterial> victimas) {
        this.victimas = victimas;
    }

    @Override
    public String toString() {
        return ReflectionToStringBuilder.toString(this, ToStringStyle.SHORT_PREFIX_STYLE);
    }

}

@Entity
@Indexed(index = "partes_materiales")
@Table(name = "partes_materiales")
public class ParteMaterial implements Serializable {

    private static final long serialVersionUID = 1L;

    @Basic
    @Column(name = "alias")
    private String alias;

    @Basic
    @Column(name = "apellido_materno")
    @Field
    private String apellidoMaterno;

    @Basic
    @Column(name = "apellido_paterno")
    @Field
    private String apellidoPaterno;

    @Basic
    @Column(name = "descripcion_persona_moral")
    private String descripcionPersonaMoral;

    @ElementCollection
    @JoinTable(name = "partes_materiales_domicilios")
    private List<Domicilio> domicilios;

    @Basic
    @Column(name = "edad")
    private Integer edad;

    @Enumerated(EnumType.STRING)
    @Column(name = "estado_civil")
    private EstadoCivil estadoCivil;

    @Temporal(TemporalType.DATE)
    @Column(name = "fecha_nacimiento")
    private Date fechaNacimiento;

    @Enumerated(EnumType.STRING)
    @Column(name = "genero")
    private Genero genero;

    @Id
    @GeneratedValue(strategy = GenerationType.TABLE)
    @Column(name = "id")
    @DocumentId
    private Integer id;

    @Basic
    @Column(name = "identificacion_personal")
    private String identificacion;

    @Basic
    @Column(name = "idioma")
    private String idioma;

    @Basic
    @Column(name = "lugar_nacimiento")
    private String lugarNacimiento;

    @Basic
    @Column(name = "nombres")
    @Field
    private String nombres;

    @Basic
    @Column(name = "profesion_oficio")
    private String profesionOrOficio;

    @Version
    @Column(name = "opt_lock")
    private Integer version;

    public ParteMaterial() {

    }

    public ParteMaterial(String alias, String apellidoMaterno, String apellidoPaterno,
            String descripcionPersonaMoral, List<Domicilio> domicilios, Integer edad,
            EstadoCivil estadoCivil, Date fechaNacimiento, Genero genero, Integer id,
            String identificacion, String idioma, String lugarNacimiento, String nombres,
            String profesionOrOficio, Integer version) {
        super();
        this.alias = alias;
        this.apellidoMaterno = apellidoMaterno;
        this.apellidoPaterno = apellidoPaterno;
        this.descripcionPersonaMoral = descripcionPersonaMoral;
        this.domicilios = domicilios;
        this.edad = edad;
        this.estadoCivil = estadoCivil;
        this.fechaNacimiento = fechaNacimiento;
        this.genero = genero;
        this.id = id;
        this.identificacion = identificacion;
        this.idioma = idioma;
        this.lugarNacimiento = lugarNacimiento;
        this.nombres = nombres;
        this.profesionOrOficio = profesionOrOficio;
        this.version = version;
    }

    @Override
    public boolean equals(Object obj) {

        if (obj == null) {
            return false;
        }
        if (obj == this) {
            return true;
        }
        if (!(obj instanceof ParteMaterial)) {
            return false;
        }

        ParteMaterial o = (ParteMaterial) obj;

        return new EqualsBuilder().append(this.nombres, o.nombres)
                .append(this.apellidoPaterno, o.apellidoPaterno)
                .append(this.apellidoMaterno, o.apellidoMaterno)
                .append(this.descripcionPersonaMoral, o.descripcionPersonaMoral).isEquals();
    }

    public String getAlias() {
        return this.alias;
    }

    public String getApellidoMaterno() {
        return this.apellidoMaterno;
    }

    public String getApellidoPaterno() {
        return this.apellidoPaterno;
    }

    public String getDescripcionPersonaMoral() {
        return this.descripcionPersonaMoral;
    }

    public List<Domicilio> getDomicilios() {
        return this.domicilios;
    }

    public Integer getEdad() {
        return this.edad;
    }

    public EstadoCivil getEstadoCivil() {
        return this.estadoCivil;
    }

    public Date getFechaNacimiento() {
        return this.fechaNacimiento;
    }

    public Genero getGenero() {
        return this.genero;
    }

    public Integer getId() {
        return this.id;
    }

    public String getIdentificacion() {
        return this.identificacion;
    }

    public String getIdioma() {
        return this.idioma;
    }

    public String getLugarNacimiento() {
        return this.lugarNacimiento;
    }

    public String getNombres() {
        return this.nombres;
    }

    public String getProfesionOrOficio() {
        return this.profesionOrOficio;
    }

    public Integer getVersion() {
        return this.version;
    }

    @Override
    public int hashCode() {
        return new HashCodeBuilder(31, 147).append(this.nombres).append(this.apellidoPaterno)
                .append(this.apellidoMaterno).append(this.descripcionPersonaMoral).toHashCode();
    }

    public void setAlias(String alias) {
        this.alias = alias;
    }

    public void setApellidoMaterno(String apellidoMaterno) {
        this.apellidoMaterno = apellidoMaterno;
    }

    public void setApellidoPaterno(String apellidoPaterno) {
        this.apellidoPaterno = apellidoPaterno;
    }

    public void setDescripcionPersonaMoral(String descripcionPersonaMoral) {
        this.descripcionPersonaMoral = descripcionPersonaMoral;
    }

    public void setDomicilios(List<Domicilio> domicilios) {
        this.domicilios = domicilios;
    }

    public void setEdad(Integer edad) {
        this.edad = edad;
    }

    public void setEstadoCivil(EstadoCivil estadoCivil) {
        this.estadoCivil = estadoCivil;
    }

    public void setFechaNacimiento(Date fechaNacimiento) {
        this.fechaNacimiento = fechaNacimiento;
    }

    public void setGenero(Genero genero) {
        this.genero = genero;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public void setIdentificacion(String identificacion) {
        this.identificacion = identificacion;
    }

    public void setIdioma(String idioma) {
        this.idioma = idioma;
    }

    public void setLugarNacimiento(String lugarNacimiento) {
        this.lugarNacimiento = lugarNacimiento;
    }

    public void setNombres(String nombres) {
        this.nombres = nombres;
    }

    public void setProfesionOrOficio(String profesionOrOficio) {
        this.profesionOrOficio = profesionOrOficio;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }

    @Override
    public String toString() {
        return ReflectionToStringBuilder.toString(this, ToStringStyle.SHORT_PREFIX_STYLE);
    }

}

弹簧配置:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:util="http://www.springframework.org/schema/util"
    xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverClassName" value="${datasource.driverClassName}" />
        <property name="url" value="${datasource.url}" />
        <property name="username" value="${datasource.username}" />
        <property name="password" value="${datasource.password}" />
        <property name="initialSize" value="${datasource.poolInitialSize}" />
    </bean>

    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="configLocation" value="classpath:hibernate.cfg.xml" />
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.current_session_context_class">
                    mx.gob.jgtjo.apps.schedule.web.conversation.ConversationalCurrentSessionContext
                </prop>
                <prop key="hibernate.dialect">${org.hibernate.dialect.dialectmysqlInno}</prop>
                <prop key="hibernate.hbm2ddl.auto">${org.hibernate.ddl.mode}</prop>
                <prop key="hibernate.connection.release_mode">${org.hibernate.transaction.release_mode}</prop>
                <prop key="hibernate.search.default.directory_provider">${org.hibernate.search.directoryprovidr}</prop>
                <prop key="hibernate.search.default.indexBase">
                    ${org.hibernate.search.index.base_directory}
                </prop>
            </props>
        </property>
    </bean>

    <bean id="transactionManager"
        class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />
        <property name="dataSource" ref="dataSource" />
        <property name="hibernateManagedSession" value="true" />
    </bean>

    <tx:annotation-driven order="0" transaction-manager="transactionManager" />

    <context:component-scan base-package="mx.gob.jgtjo.apps.schedule.dao.hibernate" />

</beans>

休眠配置

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
                                         "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory name="jgtjoSessionFactory">
        <!--Entity -->
        <mapping class="mx.gob.jgtjo.apps.schedule.model.AudienciaOral" />
        <mapping class="mx.gob.jgtjo.apps.schedule.model.CausaPenal" />
        <mapping class="mx.gob.jgtjo.apps.schedule.model.DefensorPenal" />
        <mapping class="mx.gob.jgtjo.apps.schedule.model.Delito" />
        <mapping class="mx.gob.jgtjo.apps.schedule.model.EventoAudiencia" />
        <mapping class="mx.gob.jgtjo.apps.schedule.model.Juez" />
        <mapping class="mx.gob.jgtjo.apps.schedule.model.MinisterioPublico" />
        <mapping class="mx.gob.jgtjo.apps.schedule.model.ParteMaterial" />
        <mapping class="mx.gob.jgtjo.apps.schedule.model.Sala" />
        <mapping class="mx.gob.jgtjo.apps.schedule.model.TipoAudiencia" />
        <mapping class="mx.gob.jgtjo.apps.schedule.model.User" />
        <mapping class="mx.gob.jgtjo.apps.schedule.model.Rol" />
        <mapping class="mx.gob.jgtjo.apps.schedule.model.DelitoConfigurado" />

    </session-factory>
</hibernate-configuration>

还有我的一些记录:

09:33:18,767 [ssIndexerServiceImpl] (tp-bio-8080"-exec-10) DEBUG : Indexing entities
09:33:18,773 [orphicIndexHierarchy] (tp-bio-8080"-exec-10) TRACE : Targeted indexed classes for [class java.lang.Object]: [class mx.gob.jgtjo.apps.schedule.model.CausaPenal, class mx.gob.jgtjo.apps.schedule.model.ParteMaterial]
09:33:18,774 [MassIndexerImpl     ] (tp-bio-8080"-exec-10) DEBUG : Targets for indexing job: [class mx.gob.jgtjo.apps.schedule.model.CausaPenal, class mx.gob.jgtjo.apps.schedule.model.ParteMaterial]
09:33:18,819 [orphicIndexHierarchy] (tp-bio-8080"-exec-10) TRACE : Targeted indexed classes for [class mx.gob.jgtjo.apps.schedule.model.CausaPenal, class mx.gob.jgtjo.apps.schedule.model.ParteMaterial]: [class mx.gob.jgtjo.apps.schedule.model.CausaPenal, class mx.gob.jgtjo.apps.schedule.model.ParteMaterial]
09:33:18,869 [Workspace           ] (tp-bio-8080"-exec-10) TRACE : IndexWriter opened using batch configuration
09:33:18,869 [PurgeAllWorkDelegate] (tp-bio-8080"-exec-10) TRACE : purgeAll Lucene index using IndexWriter for type: class mx.gob.jgtjo.apps.schedule.model.CausaPenal
09:33:18,889 [Workspace           ] (tp-bio-8080"-exec-10) TRACE : IndexWriter opened using batch configuration
09:33:18,890 [PurgeAllWorkDelegate] (tp-bio-8080"-exec-10) TRACE : purgeAll Lucene index using IndexWriter for type: class mx.gob.jgtjo.apps.schedule.model.ParteMaterial
09:33:18,891 [OptimizeWorkDelegate] (tp-bio-8080"-exec-10) TRACE : optimize Lucene index: class mx.gob.jgtjo.apps.schedule.model.CausaPenal
09:33:18,893 [OptimizeWorkDelegate] (tp-bio-8080"-exec-10) TRACE : optimize Lucene index: class mx.gob.jgtjo.apps.schedule.model.ParteMaterial
09:33:18,940 [WrapInJTATransaction] ( collectionsloader-2) TRACE : TransactionFactory does not require a TransactionManager: don't wrap in a JTA transaction
09:33:18,940 [WrapInJTATransaction] ( collectionsloader-3) TRACE : TransactionFactory does not require a TransactionManager: don't wrap in a JTA transaction
09:33:18,940 [WrapInJTATransaction] ( collectionsloader-2) TRACE : TransactionFactory does not require a TransactionManager: don't wrap in a JTA transaction
09:33:18,944 [nsumerEntityProducer] (hIndexingWorkspace-2) TRACE : created
09:33:18,946 [WrapInJTATransaction] ( collectionsloader-4) TRACE : TransactionFactory does not require a TransactionManager: don't wrap in a JTA transaction
09:33:18,947 [nsumerEntityProducer] (hIndexingWorkspace-2) TRACE : created
09:33:18,948 [WrapInJTATransaction] (arch: entityloader-1) TRACE : TransactionFactory does not require a TransactionManager: don't wrap in a JTA transaction
09:33:18,932 [WrapInJTATransaction] ( collectionsloader-1) TRACE : TransactionFactory does not require a TransactionManager: don't wrap in a JTA transaction
09:33:18,932 [WrapInJTATransaction] ( collectionsloader-1) TRACE : TransactionFactory does not require a TransactionManager: don't wrap in a JTA transaction
09:33:18,950 [WrapInJTATransaction] (arch: entityloader-2) TRACE : TransactionFactory does not require a TransactionManager: don't wrap in a JTA transaction
09:33:18,951 [WrapInJTATransaction] ( collectionsloader-3) TRACE : TransactionFactory does not require a TransactionManager: don't wrap in a JTA transaction
09:33:18,974 [IdentifierProducer  ] (hIndexingWorkspace-2) TRACE : created
09:33:18,948 [nsumerEntityProducer] (arch: entityloader-1) TRACE : started
09:33:18,973 [WrapInJTATransaction] ( collectionsloader-4) TRACE : TransactionFactory does not require a TransactionManager: don't wrap in a JTA transaction
09:33:18,951 [nsumerEntityProducer] (hIndexingWorkspace-1) TRACE : created
09:33:18,950 [nsumerEntityProducer] (arch: entityloader-2) TRACE : started
09:33:18,975 [WrapInJTATransaction] (: identifierloader-1) TRACE : TransactionFactory does not require a TransactionManager: don't wrap in a JTA transaction
09:33:18,978 [nsumerEntityProducer] (hIndexingWorkspace-1) TRACE : created
09:33:18,978 [WrapInJTATransaction] (arch: entityloader-1) TRACE : TransactionFactory does not require a TransactionManager: don't wrap in a JTA transaction
09:33:18,979 [nsumerEntityProducer] (arch: entityloader-1) TRACE : started
09:33:18,977 [IdentifierProducer  ] (: identifierloader-1) TRACE : started
09:33:18,979 [IdentifierProducer  ] (hIndexingWorkspace-1) TRACE : created
09:33:18,988 [WrapInJTATransaction] (arch: entityloader-2) TRACE : TransactionFactory does not require a TransactionManager: don't wrap in a JTA transaction
09:33:18,989 [nsumerEntityProducer] (arch: entityloader-2) TRACE : started
09:33:19,049 [WrapInJTATransaction] (: identifierloader-1) TRACE : TransactionFactory does not require a TransactionManager: don't wrap in a JTA transaction
09:33:19,050 [IdentifierProducer  ] (: identifierloader-1) TRACE : started

我不知道为什么,但在我看来,休眠搜索不知何故进入了无限循环。欢迎任何帮助。


如果您还没有弄清楚,请检查允许的最大连接数,因为质量索引器使用大量连接。例如,如果您使用像 c3p0 这样的池数据源:

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
    <property name="user" value="username"/>
    <property name="password" value="password"/>
    <property name="driverClass" value="oracle.jdbc.driver.OracleDriver"/>
    <property name="jdbcUrl" value="jdbc:oracle:thin:@my.dbserver.com:1521:PRODUCTION"/>
    <property name="initialPoolSize" value="1"/>
    <property name="minPoolSize" value="1"/>
    <property name="maxPoolSize" value="10"/>
</bean>

尝试将initialPoolSize 设置为3,将maxPoolSize 设置为100 或更高,然后重试。

希望有帮助!

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

为什么 Hibernate Search 需要花费这么多时间来构建索引? 的相关文章

  • 如何在一行中将字符串数组转换为双精度数组

    我有一个字符串数组 String guaranteedOutput Arrays copyOf values values length String class 所有字符串值都是数字 数据应转换为Double QuestionJava 中
  • 我需要在 Spring 中检查每个控制器中的有效会话吗? [关闭]

    Closed 这个问题需要多问focused help closed questions 目前不接受答案 假设在 Spring Mvc 的 Web 应用程序中 我们是否需要检查每个控制器或 jsps 中的有效会话 我该如何解决 MVC 中的
  • ElasticBeanstalk Java,Spring 活动配置文件

    我正在尝试通过 AWS ElasticBeanstalk 启动 spring boot jar 一切正常 配置文件为 默认 有谁知道如何为 java ElasticBeanstalk 应用程序 不是 tomcat 设置活动配置文件 spri
  • 开始 Java EE

    我对 Java 了解一些 但对 Enterprise Java 完全陌生 我正在尝试使用 NetBeans 6 1 和 GlassFish 应用服务器 请指导我一些资源 这些资源实际上告诉我什么是 java 企业应用程序 它们与普通 jav
  • 解决错误:日志已在具有多个实例的atomikos中使用

    我仅在使用atomikos的实时服务器上遇到问题 在我的本地服务器上它工作得很好 我在服务器上面临的问题是 init 中出错 日志已在使用中 完整的异常堆栈跟踪 java lang RuntimeException Log already
  • Java8无符号算术

    据广泛报道 Java 8 具有对无符号整数的库支持 然而 似乎没有文章解释如何使用它以及有多少可能 有些函数 例如 Integer CompareUnsigned 很容易找到 并且似乎可以实现人们所期望的功能 但是 我什至无法编写一个简单的
  • CXF Swagger2功能添加安全定义

    我想使用 org apache cxf jaxrs swagger Swagger2Feature 将安全定义添加到我的其余服务中 但是我看不到任何相关方法或任何有关如何执行此操作的资源 下面是我想使用 swagger2feature 生成
  • 使用 ANTLR 为 java 源代码生成抽象语法树

    如何使用 ANTLR 从 java src 代码生成 AST 有什么帮助吗 好的 步骤如下 前往ANTLR站点 http www antlr org 并下载最新版本 下载Java g和JavaTreeParser g文件来自here htt
  • 当分配给变量时,我可以以某种方式重用 Gremlin GraphTraversals 代码吗?

    我有看起来像这样的 GraphTraversals attrGroup GraphTraversal
  • hibernate总是自己删除表中的所有数据

    您好 我正在开发一个 spring mvc 应用程序 它使用 hibernate 连接到存储文件的 mysql 数据库 我有两个方法 一个方法添加我选择的特定文件路径中的所有文件 另一种方法调用查询以返回从 mysql 存储的文件列表 问题
  • 使用替换字符串中多个单词的最有效方法[重复]

    这个问题在这里已经有答案了 此刻我正在做 Example line replaceAll replaceAll cat dog replaceAll football rugby 我觉得那很丑 不确定有更好的方法吗 也许循环遍历哈希图 ED
  • Clip 在 Java 中播放 WAV 文件时出现严重延迟

    我编写了一段代码来读取 WAV 文件 大小约为 80 mb 并播放该文件 问题是声音播放效果很差 极度滞后 你能告诉我有什么问题吗 这是我的代码 我称之为doPlayJframe 构造函数内的函数 private void doPlay f
  • 从 android 简单上传到 S3

    我在网上搜索了从 android 上传简单文件到 s3 的方法 但找不到任何有效的方法 我认为这是因为缺乏具体步骤 1 https mobile awsblog com post Tx1V588RKX5XPQB TransferManage
  • 如何在 JFreeChart TimeSeries 图表上显示降雨指数和温度?

    目前 我的 TimeSeries 图表每 2 秒显示一个位置的温度 现在 如果我想每2秒显示一次降雨指数和温度 我该如何实现呢 这是我的代码 import testWeatherService TestWeatherTimeLapseSer
  • Tomcat 6找不到mysql驱动

    这里有一个类似的问题 但关于类路径 ClassNotFoundException com mysql jdbc Driver https stackoverflow com questions 1585811 classnotfoundex
  • 使用 SAX 进行 XML 解析 |如何处理特殊字符?

    我们有一个 JAVA 应用程序 可以从 SAP 系统中提取数据 解析数据并呈现给用户 使用 SAP JCo 连接器提取数据 最近我们抛出了一个异常 org xml sax SAXParseException 字符引用 是无效的 XML 字符
  • 当单元格内的 JComboBox 中有 ItemEvent 时,如何获取 CellRow

    我有一个 JTable 其中有一列包含 JComboBox 我有一个附加到 JComboBox 的 ItemListener 它会根据任何更改进行操作 但是 ItemListener 没有获取更改的 ComboBox 所在行的方法 当组合框
  • 运行 Jar 文件时出现问题

    我已将 java 项目编译成 Jar 文件 但运行它时遇到问题 当我跑步时 java jar myJar jar 我收到以下错误 Could not find the main class myClass 类文件不在 jar 的根目录中 因
  • KeyPressed 和 KeyTyped 混淆[重复]

    这个问题在这里已经有答案了 我搜索过之间的区别KeyPressedand KeyTyped事件 但我仍然不清楚 我发现的一件事是 Keypressed 比 KeyTyped 首先被触发 请澄清一下这些事件何时被准确触发 哪个适合用于哪个目的
  • 中断连接套接字

    我有一个 GUI 其中包含要连接的服务器列表 如果用户单击服务器 则会连接到该服务器 如果用户单击第二个服务器 它将断开第一个服务器的连接并连接到第二个服务器 每个新连接都在一个新线程中运行 以便程序可以执行其他任务 但是 如果用户在第一个

随机推荐

  • SWI-Prolog 中的 catch/3 和 call_with_time_limit/2 谓词

    我想用 catch Goal Catcher Recover 目标在哪里 call with time limit Time Goal 它很混乱 我找不到正确的方法来知道上述情况之一何时发生 1 进球因超时而停止 2 目标失败 有时应该会失
  • 如何使用 React Router 将 div 放入 Switch 中?

    我有一个使用 React 和 Redux 的 APP 我想加载一个NotFound当用户输入无效路线时的组件 我在网上找到了解决这个问题的方法 那就是将所有路由放在一个交换机中 包括NotFound成分 问题是 在我的应用程序中 我无法将所
  • 使用 .NET 4.5 async、await 将 Azure blob 异步下载到字符串

    我正在尝试实施一个完全异步使用 NET 4 5 异步和等待进行 blob 下载 假设整个 blob 可以一次放入内存中 并且我们希望将其保存在string Code public async Task
  • 来自 Xib 的 Cell 与 Swift 3

    我已经阅读并看过一些有关此主题的视频 但我无法让它发挥作用 我正在尝试使用 xib 中的单元格而不是故事板 这是我的 ViewController 其中有表视图 import UIKit class ViewController UIVie
  • panelgrid 内的复合组件未“扩展”

    基本上 我一直在 panelgrid 中一次又一次地使用这种模式
  • 如果我在 Python 脚本运行时修改它会发生什么?

    想象一下 一个Python脚本需要很长时间才能运行 如果我在它运行时修改它会发生什么 结果会不同吗 没什么 因为 Python 将你的脚本预编译成 PYC 文件并启动它 但是 如果发生某种异常 您可能会得到一个稍微误导性的解释 因为行X可能
  • PHP:我如何知道函数的调用者?

    我如何知道 php 中函数的调用者 不知道为什么你会关心这个 但你可以从debug backtrace http php net debug backtrace功能
  • 调整窗口大小时自动调整文本大小(字体大小)?

    我一直在尝试 徒劳地 构建一个页面 其元素会随着我更改窗口大小而调整大小 我让它在图像的 CSS 中工作没有问题 但我似乎无法在文本中完成同样的工作 而且我不确定它在 CSS 中是否可能 我似乎找不到一个 jquery 脚本来完成这个任务
  • Chrome 教程 - 选项页面

    我正在开发我的第一个 chrome 扩展 我关注了这篇文章http code google com chrome extensions options html http code google com chrome extensions
  • 合并大量netCDF文件

    我有一个包含 netCDF nc 文件的大文件夹 每个文件都具有相似的名称 数据文件包含时间 经度 纬度和月降水量的变量 目标是获取 X 年内每个月的平均月降水量 所以最后我会得到 12 个值 代表 X 年内每个纬度和经度的平均月降水量 多
  • 使用 HttpModule 的 WCF URL 重定向

    我想将 Service1 的所有请求重定向到 Service2 我尝试使用 HTTPModule 进行此操作 但我没有运气 请建议任何方法来实现这一目标 非常感谢 可以通过内置的方法来完成代码密集程度较低的重定向调用的方法WCF 路由服务
  • 有序字典,保留初始顺序

    有序字典 import collections d banana 3 apple 4 pear 1 orange 2 collections OrderedDict sorted d items key lambda t t 0 上面的例子
  • Angular 5 材质多垫菜单

    I am quite new to Angular 5 and have just started learning it Recently I have been trying to create a menu bar with mult
  • 样式 AutoCompleteBox 错误指示器

    是否可以更改当 WPF 工具包中的 AutoCompleteBox 出现错误时出现的红色矩形的样式 我成功地在 TextBox 上更改了它 只是为控件创建了一个新样式 但无论我对 AutoCompleteBox 做什么 我都无法摆脱那个红色
  • 将 LibGDX 与 Android 首选项结合使用

    我正在尝试将 Android 的首选项系统与 LibGDX 的首选项系统结合使用 它们都使用 SharedPreferences 作为后端 所以我认为它们应该能够一起工作 但是当我尝试在 LibGDX 的首选项中加载数据时 我没有得到任何数
  • 瓢虫调试器的一些功能在 symfony2 php 应用程序中不起作用

    我正在用这个 https github com raulfraile LadybugBundle https github com raulfraile LadybugBundle 它们具有三个功能 ld var1 var2 shortcu
  • 运行 pod 和节点的 Kubernetes prometheus 指标?

    我已经设置了 prometheus 通过遵循 prometheus 来监控 kubernetes 指标文档 https github com prometheus docs blob master content docs operatin
  • MySQL - 持久连接与连接池

    为了避免每次需要向 MySQL 发起查询时建立新连接的开销 有两个选项可用 持久连接 请求新连接时会检查 相同 连接是否已打开 如果已打开 则使用它 连接池 客户端维护一个连接池 以便每个需要使用连接的线程将从池中取出一个连接 并在完成后将
  • 查看 CFHTTP 调用的原始 HTML

    有没有办法输出原始htmlCFHTTP称呼 我试图了解一些标头身份验证信息是如何出现的 我对浏览器插件或代码更新持开放态度 只要能帮助我了解期间发生的情况即可cfhttp call 例如
  • 为什么 Hibernate Search 需要花费这么多时间来构建索引?

    我正在尝试通过 hibernate 搜索构建 lucene 索引FullTextSession createIndexer startAndWait 但即使测试数据非常少 它也不会结束 这是我的代码 Component hibernateS