RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-243759

Max Lich's questions

Martin Hope
Max Lich
Asked: 2020-05-21 17:07:32 +0000 UTC

为什么在 Excel 导出中出现错误 org.springframework.web.HttpMediaTypeNotAcceptableException:找不到可接受的表示?

  • 1

我用apache poi它上传到MS Excel. 我也用Spring. 库版本:

<springframework.boot>2.1.2.RELEASE</springframework.boot>
<springframework.version>5.1.4.RELEASE</springframework.version>
<apache-poi.version>4.0.1</apache-poi.version>

在控制器中提交文件时,出现错误:

   ERROR] 2019-05-21 11:50:45.992 [http-nio-9999-exec-2] RestExceptionHandler - Could not find acceptable representation
org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation

这是我的控制器代码:

 @RestController
@RequestMapping(produces = "application/vnd.ms-excel")
@Api(tags = {"ExportToMsExcelController"}, description = "Выгрузка в MS Excel"/*, produces = "application/vnd.ms-excel"*/)
public class ExportToMsExcelController {

    private final static Logger logger = LogManager.getLogger(ExportToMsExcelController.class);

    private static final String REQUEST_FILE_PREFIX = "RequestRegistry";

    private CreateRequestXLSXDocumentService createRequestXLSXDocumentService;

    @Autowired
    public void setCreateRequestXLSXDocumentService(CreateRequestXLSXDocumentService createRequestXLSXDocumentService) {
        this.createRequestXLSXDocumentService = createRequestXLSXDocumentService;
    }

    @ResponseStatus(HttpStatus.OK)
    @GetMapping(value = "/requests/list/ms-excel")
    @ApiOperation(value = "Экспортирует таблицу \"Реестр заявлений\" в MS Excel",
            notes = "Экспортирует данные таблицы \"Реестр заявлений\" в файл в формате MS Excel")
    public ResponseEntity<InputStreamResource> exportRequestTable(
            @ApiParam(value = "Optional String sort (example atr-,atr2,atr3)", name = "sort") @RequestParam(value = "sort", required = false) String sort,
            @ApiParam(value = "Optional String search (example evId==541)", name = "search") @RequestParam(value = "search", required = false) String search
    ) {

        Map<String, Object> param = new HashMap<>();

        final long startTime = System.currentTimeMillis();

        Optional.ofNullable(sort).ifPresent(s -> param.put("sort", s));

        Optional.ofNullable(search).ifPresent(s -> param.put("search", s));

        byte[] fileCont;
        try {
            fileCont = createRequestXLSXDocumentService.createXLSXDocument(param);
        } catch (Exception ex) {
            logger.error(ex.toString(), ex);
            throw new RuntimeException(ex.getMessage(), ex);
        }

        final ByteArrayInputStream in = new ByteArrayInputStream(fileCont);

        final String fileName = generateFileName(REQUEST_FILE_PREFIX);

        HttpHeaders headers = new HttpHeaders();
        // set filename in header
        headers.add(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + fileName);

        final long endTime = System.currentTimeMillis();

        logger.info("Общее время работы: " + ((endTime - startTime) / 1000) + " сек");

        return ResponseEntity
                .ok()
                .headers(headers)
                .contentLength(fileCont.length)
                .contentType(MediaType.parseMediaType("application/vnd.ms-excel"))
                .body(new InputStreamResource(in));
    }

    /**
     * Генерирует имя файла
     *
     * @param prefix префикс в имени файла
     * @return сгенерированное имя файла
     */
    private String generateFileName(String prefix) {
        return String.format("%s_%s.xlsx", prefix,
                LocalDateTime.now()
                        .toString()
                        .replace(':', '-')
        );
    }
}
java
  • 1 个回答
  • 10 Views
Martin Hope
Max Lich
Asked: 2020-04-20 15:30:37 +0000 UTC

如何使用肥皂在 Tomcat 9 上部署 java 11 Web 服务而没有痛苦和痛苦?

  • 0

写了一个服务——一个在soap上工作的web客户端,11日Java写的。起初我找不到合适的soap 和web 服务库。最后,我选择了这些:

<dependency>
                    <groupId>com.sun.xml.ws</groupId>
                    <artifactId>rt</artifactId>
                    <version>2.3.1</version>
                </dependency>
                <dependency>
                    <groupId>com.sun.xml.ws</groupId>
                    <artifactId>jaxws-rt</artifactId>
                    <version>2.3.1</version>
                    <type>pom</type>
                </dependency>

我从服务中丢弃了几乎所有的库(内部库除外)。我把所有jars形式的库都扔到Tomcat的lib目录下。并且在部署时,它会写入以下错误:

...
java.nio.file.NoSuchFileException: C:\tomcat\apache-tomcat-9.0.14\lib\hk2-core.jar
...
java.nio.file.NoSuchFileException: C:\tomcat\apache-tomcat-9.0.14\lib\class-model.jar
...
java.nio.file.NoSuchFileException: C:\tomcat\apache-tomcat-9.0.14\lib\config.jar
...
java.nio.file.NoSuchFileException: C:\tomcat\apache-tomcat-9.0.14\lib\auto-depends.jar
...
java.nio.file.NoSuchFileException: C:\tomcat\apache-tomcat-9.0.14\lib\javax.inject.jar
...
java.nio.file.NoSuchFileException: C:\tomcat\apache-tomcat-9.0.14\lib\hk2-api.jar
...
java.nio.file.NoSuchFileException: C:\tomcat\apache-tomcat-9.0.14\lib\osgi-resource-locator.jar
....
java.nio.file.NoSuchFileException: C:\tomcat\apache-tomcat-9.0.14\lib\tiger-types.jar
...
java.nio.file.NoSuchFileException: C:\tomcat\apache-tomcat-9.0.14\lib\bean-validator.jar
...
 java.nio.file.NoSuchFileException: C:\tomcat\apache-tomcat-9.0.14\lib\jtype.jar
...

我尝试在互联网上搜索这些库,但非常费力。找了个东西,放到lib文件夹下,还是写了这些错误。然后我注意到罐子的名称不匹配 - 我添加了更多版本。但我没有改名字:我不再确定这是不是正确的方法,而且它也相当乏味和耗时。

我放在 lib 文件夹中的库

java
  • 1 个回答
  • 10 Views
Martin Hope
Max Lich
Asked: 2020-11-15 22:25:10 +0000 UTC

如果服务任务或脚本任务在 bpm 方案中的计时器之后出现,则会出现错误(Alfresco 的 Activiti 6)

  • 0

关于Alfresco的Activiti的问题 6.如果我在scheme中的timer(or)后面加了一个block ,就会出现intermediate timer catching event错误,进程就不会继续下去了。如果有一个 block ,那么就会出现这个错误:boundary timer eventservice taskscript taskservice task

无法实例化 <full_class_name>

其中 <full_class_name> 是service task为class.

如果script task是这样的:

找不到“groovy”的脚本引擎

同时,还有一个用于service taskin的类,也连接classpath了引擎的库。groovy最有趣的是,这些错误并不总是出现,在 5-10 个案例中,有 1 个可以正常工作。没找到图案。

PS 我尝试service task在我的工作项目(使用RESTand Spring Web Mvc)和一个用Swing. 错误发生在这里和那里。

为了详细描述,尝试了以下方法来解决这个问题:

  • 在测试应用程序中:

    • src/main/java一个类被放置在目录中(此外,它被写WEB-INF.classes.<пакеты_класса>.<короткое_имя_класса>在类本身的文件中) - 它没有帮助package<пакеты_класса>
    • src/main/java目录WEB-INF/classes/<пакеты_класса>中放置了一个包含已编译类的目录(此外, package<class_packages> 也写在类本身的文件中) - 没有帮助
  • 在工作项目中,src/main/java将一个类添加到目录中(此外,<class_packages> 写<пакеты_класса>. <короткое_имя_класса>在类本身的文件中) - 它没有帮助package

同时,在最终归档与应用程序(jar或war类在目录中WEB-INF/classes/<пакеты_класса>)。同时,在工作项目中,在依赖项中(因此,在目录WEB-INF/lib或lib服务器目录中Tomcat),有一个带有此类的 jar 位于正确的包中,这也没有帮助。

PS我的测试过程定义示例:

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/processdef">
  <process id="MaxShulTest_v20" name="MaxShulTest" isExecutable="true">
    <documentation>test process</documentation>
    <startEvent id="startEvent1"></startEvent>
    <userTask id="Task1" name="Task1"></userTask>
    <userTask id="Task4" name="Task4"></userTask>
    <userTask id="Task2" name="Task2"></userTask>
    <sequenceFlow id="sid-FEBA8018-5838-4AF2-8AE5-DED45EF36229" sourceRef="Task1" targetRef="Task2"></sequenceFlow>
    <sequenceFlow id="sid-A71A6EB8-293E-4EA7-A876-670C8E4ABF7C" sourceRef="Task2" targetRef="ExclusiveGateway1"></sequenceFlow>
    <sequenceFlow id="sid-1691D37B-9B00-452F-B031-124B3845912B" sourceRef="Task4" targetRef="ExclusiveGateway1"></sequenceFlow>
    <endEvent id="endEvent1"></endEvent>
    <sequenceFlow id="sid-EAC37DEB-9666-407E-8EE0-27C11CEC4302" sourceRef="ExclusiveGateway1" targetRef="endEvent1"></sequenceFlow>
    <exclusiveGateway id="ExclusiveGateway1"></exclusiveGateway>
    <boundaryEvent id="boundary_timer1" attachedToRef="Task1" cancelActivity="true">
      <timerEventDefinition>
        <timeDuration>PT1M</timeDuration>
      </timerEventDefinition>
    </boundaryEvent>
    <sequenceFlow id="sid-88CC1D13-0907-44CC-ACAE-6E2FC01C8A3F" sourceRef="startEvent1" targetRef="service_task_1"></sequenceFlow>
    <serviceTask id="service_task_1" name="service_task_1" activiti:class="ru.maxlich.app.test.activiti.model.service.LogDelegateService"></serviceTask>
    <sequenceFlow id="sid-B9705ABC-78B3-460A-80ED-613EE3147491" sourceRef="service_task_2" targetRef="Task1"></sequenceFlow>
    <intermediateCatchEvent id="timer_1" name="timer_1">
      <timerEventDefinition>
        <timeDuration>PT3M</timeDuration>
      </timerEventDefinition>
    </intermediateCatchEvent>
    <sequenceFlow id="sid-49554231-BC08-4237-8B48-6D5484289319" sourceRef="service_task_1" targetRef="timer_1"></sequenceFlow>
    <sequenceFlow id="sid-7C4E0E46-E680-45F2-847F-8C37FFB16C53" sourceRef="timer_1" targetRef="service_task_2"></sequenceFlow>
    <serviceTask id="service_task_2" name="service_task_2" activiti:class="ru.maxlich.app.test.activiti.model.service.LogDelegateService"></serviceTask>
    <sequenceFlow id="sid-727BA009-3FE2-48DE-B41E-693FCE3D2F53" sourceRef="boundary_timer1" targetRef="service_task_3"></sequenceFlow>
    <serviceTask id="service_task_3" name="service_task_3" activiti:class="ru.maxlich.app.test.activiti.model.service.LogDelegateService"></serviceTask>
    <sequenceFlow id="sid-7F9D801A-5C8F-4623-987E-2E3FC936126E" sourceRef="service_task_3" targetRef="Task4"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_MaxShulTest_v20">
    <bpmndi:BPMNPlane bpmnElement="MaxShulTest_v20" id="BPMNPlane_MaxShulTest_v20">
      <bpmndi:BPMNShape bpmnElement="startEvent1" id="BPMNShape_startEvent1">
        <omgdc:Bounds height="30.0" width="30.0" x="30.0" y="185.943858356366"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="Task1" id="BPMNShape_Task1">
        <omgdc:Bounds height="80.0" width="100.0" x="559.25" y="134.5"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="Task4" id="BPMNShape_Task4">
        <omgdc:Bounds height="80.0" width="100.0" x="855.0" y="286.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="Task2" id="BPMNShape_Task2">
        <omgdc:Bounds height="80.0" width="100.0" x="783.25" y="135.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endEvent1" id="BPMNShape_endEvent1">
        <omgdc:Bounds height="28.0" width="28.0" x="1122.25" y="189.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="ExclusiveGateway1" id="BPMNShape_ExclusiveGateway1">
        <omgdc:Bounds height="40.0" width="40.0" x="1019.5" y="183.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="boundary_timer1" id="BPMNShape_boundary_timer1">
        <omgdc:Bounds height="31.0" width="31.0" x="608.0803504247281" y="199.943858356366"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="service_task_1" id="BPMNShape_service_task_1">
        <omgdc:Bounds height="71.0" width="110.0" x="135.0" y="138.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="timer_1" id="BPMNShape_timer_1">
        <omgdc:Bounds height="31.0" width="31.0" x="303.13336181640625" y="158.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="service_task_2" id="BPMNShape_service_task_2">
        <omgdc:Bounds height="82.0" width="107.0" x="390.0" y="133.5"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="service_task_3" id="BPMNShape_service_task_3">
        <omgdc:Bounds height="82.0" width="107.0" x="630.0" y="285.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="sid-727BA009-3FE2-48DE-B41E-693FCE3D2F53" id="BPMNEdge_sid-727BA009-3FE2-48DE-B41E-693FCE3D2F53">
        <omgdi:waypoint x="630.9660814288677" y="229.07107294829532"></omgdi:waypoint>
        <omgdi:waypoint x="661.2786598187816" y="285.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-FEBA8018-5838-4AF2-8AE5-DED45EF36229" id="BPMNEdge_sid-FEBA8018-5838-4AF2-8AE5-DED45EF36229">
        <omgdi:waypoint x="659.25" y="174.61160714285714"></omgdi:waypoint>
        <omgdi:waypoint x="783.25" y="174.88839285714286"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-B9705ABC-78B3-460A-80ED-613EE3147491" id="BPMNEdge_sid-B9705ABC-78B3-460A-80ED-613EE3147491">
        <omgdi:waypoint x="497.0" y="174.5"></omgdi:waypoint>
        <omgdi:waypoint x="559.25" y="174.5"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-EAC37DEB-9666-407E-8EE0-27C11CEC4302" id="BPMNEdge_sid-EAC37DEB-9666-407E-8EE0-27C11CEC4302">
        <omgdi:waypoint x="1059.5" y="203.0"></omgdi:waypoint>
        <omgdi:waypoint x="1122.25" y="203.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-A71A6EB8-293E-4EA7-A876-670C8E4ABF7C" id="BPMNEdge_sid-A71A6EB8-293E-4EA7-A876-670C8E4ABF7C">
        <omgdi:waypoint x="883.25" y="181.7795571220596"></omgdi:waypoint>
        <omgdi:waypoint x="1021.9182556711604" y="200.5817443288396"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-88CC1D13-0907-44CC-ACAE-6E2FC01C8A3F" id="BPMNEdge_sid-88CC1D13-0907-44CC-ACAE-6E2FC01C8A3F">
        <omgdi:waypoint x="59.73834151603846" y="198.15436210137352"></omgdi:waypoint>
        <omgdi:waypoint x="135.0" y="183.90973937655264"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-49554231-BC08-4237-8B48-6D5484289319" id="BPMNEdge_sid-49554231-BC08-4237-8B48-6D5484289319">
        <omgdi:waypoint x="245.0" y="173.71295813578445"></omgdi:waypoint>
        <omgdi:waypoint x="303.13348175202987" y="173.93804900670392"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-7C4E0E46-E680-45F2-847F-8C37FFB16C53" id="BPMNEdge_sid-7C4E0E46-E680-45F2-847F-8C37FFB16C53">
        <omgdi:waypoint x="335.13323251092316" y="174.0643254128607"></omgdi:waypoint>
        <omgdi:waypoint x="390.0" y="174.28491016247852"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-7F9D801A-5C8F-4623-987E-2E3FC936126E" id="BPMNEdge_sid-7F9D801A-5C8F-4623-987E-2E3FC936126E">
        <omgdi:waypoint x="737.0" y="326.0"></omgdi:waypoint>
        <omgdi:waypoint x="855.0" y="326.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-1691D37B-9B00-452F-B031-124B3845912B" id="BPMNEdge_sid-1691D37B-9B00-452F-B031-124B3845912B">
        <omgdi:waypoint x="948.8221673355974" y="286.0"></omgdi:waypoint>
        <omgdi:waypoint x="1029.1648250460405" y="212.6648250460405"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>
alfresco
  • 1 个回答
  • 10 Views
Martin Hope
Max Lich
Asked: 2020-10-29 18:26:13 +0000 UTC

为什么边界计时器对我不起作用(使用 Activiti 6)?

  • 1

边界计时器不起作用。我使用的是 Activiti 6。如果我在计时器之后放了一些东西,那么该过程将遵循其通常的路线。如果我没有设置任何东西,它来自计时器的分支。同时,计时器的时间间隔无关紧要:进程立即沿着一个或另一个分支前进。我的一个带计时器的 bpm 方案: 带边界定时器的图表

为了创建对象以使用 Activity 引擎,我使用 Spring 5。这是我的配置类的一部分:

@Bean
    SpringProcessEngineConfiguration processEngineConfiguration(@Qualifier("dataSourceForActiviti") DataSource dataSourceForActiviti,
                                                                @Qualifier("transactionManagerForActiviti") PlatformTransactionManager transactionManagerForActiviti) {
        SpringProcessEngineConfiguration processEngineConfiguration = new SpringProcessEngineConfiguration();
        processEngineConfiguration.setTransactionManager(transactionManagerForActiviti);

        processEngineConfiguration.setDataSource(dataSourceForActiviti)
                .setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE)
                .setAsyncExecutorActivate(true)
        ;

        processEngineConfiguration.setDeploymentResources(new Resource[]{
                new ClassPathResource("bpm/LicensingProcess.bpmn20.xml"),
                new ClassPathResource("bpm/ReissuanceLicenseProcess.bpmn20.xml"),
                new ClassPathResource("bpm/IssueOfDuplicateProcess.bpmn20.xml"),
                new ClassPathResource("bpm/IssuanceOfCopyProcess.bpmn20.xml"),
                new ClassPathResource("bpm/TerminationOfLicenseProcess.bpmn20.xml"),
                new ClassPathResource("bpm/ExtractFromRegisterOfLicensesProcess.bpmn20.xml")
        });


        return processEngineConfiguration;
    }

    @Bean
    ProcessEngineFactoryBean processEngineFactoryBean(SpringProcessEngineConfiguration processEngineConfiguration) {
        ProcessEngineFactoryBean processEngineFactoryBean = new ProcessEngineFactoryBean();
        processEngineFactoryBean.setProcessEngineConfiguration(processEngineConfiguration);
        return processEngineFactoryBean;
    }

    @Bean
    RepositoryService repositoryService(ProcessEngineFactoryBean processEngineFactoryBean) throws Exception {
        return processEngineFactoryBean.getObject().getRepositoryService();
    }

    @Bean
    RuntimeService runtimeService(ProcessEngineFactoryBean processEngineFactoryBean) throws Exception {
        return processEngineFactoryBean.getObject().getRuntimeService();
    }

    @Bean
    TaskService taskService(ProcessEngineFactoryBean processEngineFactoryBean) throws Exception {
        return processEngineFactoryBean.getObject().getTaskService();
    }

我尝试使用方法setAsyncExecutorActivate,并将其作为参数传递true,并且false- 并没有注意到差异。虽然文档说将值设置asyncExecutorActivate为true

PS找到了这个解决方案(添加到bean定义中ProcessEngineConfiguration):

// Async Job Executor
final DefaultAsyncJobExecutor asyncExecutor = new DefaultAsyncJobExecutor();
asyncExecutor.setMaxPoolSize(50);
asyncExecutor.setQueueSize(100);
processEngineConfiguration.setAsyncExecutor(asyncExecutor);

但这对我也没有帮助。虽然添加此代码后asyncJobExecutor不再等于null

PSS 同时,这个方案在 Activiti Modeler 中效果很好。而且我还无法弄清楚,这就是为什么它在那里运行良好并且对我不起作用的原因。

PSSS 写了一个没有弹簧的简单应用程序(在秋千上)。用过类StandaloneProcessEngineConfiguration,没用过ProcessEngineBeanFactoryBean。一切都奏效了。但只有在boundary timer-a 之后才值得script taskor service task。对他们不起作用(第一个没有找到groove引擎,第二个没有看到指定的类(我标明了类的全名,肯定是有的))。如果在boundary timerstand user taskor之后manual task,那么一切正常。为什么不起作用script task,service task我仍然不明白。仍然可以尝试使用 classesSpringProcessEngineConfiguration和ProcessEngineBeanFactoryBean,以及使用 spring bean 容器。

java
  • 1 个回答
  • 10 Views
Martin Hope
Max Lich
Asked: 2020-09-24 18:32:13 +0000 UTC

如何在Activiti(ServiceTask)的表达式中使用spring bean?

  • 0

不能在 Activiti 的表达式中使用 bean(在 ServiceTask 中)。他写道,他没有看到这个垃圾箱。摘自 pom 按版本:

<springframework.version>5.0.2.RELEASE</springframework.version>
        <springframework.boot>2.0.4.RELEASE</springframework.boot>
        <activiti.version>6.0.0</activiti.version>

Bean 由类上的注释定义。bpmn 模式文件的摘录:

<serviceTask id="SendStatus104" name="Формирование и отправка статуса" activiti:expression="${sendService.sendStatusCode(104)}">
  <documentation>Формирование и отправка статуса</documentation>
</serviceTask>

类声明:

    @Service("sendService")
public class SendServiceImpl implements SendService {
//some code
}
java
  • 1 个回答
  • 10 Views
Martin Hope
Max Lich
Asked: 2020-07-24 18:22:05 +0000 UTC

如何使用 CSS 更改 QTableView 表头中的文本对齐方式?

  • 1

我使用 Siemens ( WinCC OA) 的一个程序,它基于Qt. 您不能直接使用其中的库Qt,但可以使用 更改图形对象的显示CSS。如何CSS仅使用QTableView.

像这样尝试:

 QTableView QHeaderView::section {
    text-align: center;
 }

它不起作用。

css
  • 1 个回答
  • 10 Views
Martin Hope
Max Lich
Asked: 2020-04-20 18:42:38 +0000 UTC

如何有效地对行进行分组?

  • 12

需要解决以下问题:

根据以下标准将唯一字符串集拆分为不重叠的组:

如果两行在一列或多列中有匹配的非空值,则它们属于同一组。

例如,线条

111;123;222
200;123;100
300;;100

都属于同一个组,因为前两行在第二列中具有相同的值,而后两行在第三列中123具有相同的值100

程序运行时间(30 秒)也有限制。我还可以添加行数——大约一百万。这是我的代码:

private static Set<TreeSet<Integer>> findLineGroups(List<String> lines) {
    Set<TreeSet<Integer>> resultSet = new TreeSet<>((Comparator<TreeSet<Integer>>) (trSet1, trSet2) -> {
        int diff = trSet2.size() - trSet1.size();
        if (diff != 0)
            return diff;

        Iterator<Integer> iterator1 = trSet1.iterator();
        Iterator<Integer> iterator2 = trSet2.iterator();
        while (iterator1.hasNext()) {
            diff = iterator1.next() - iterator2.next();
            if (diff != 0)
                return diff;
        }

        return 0;
    });

    Map<String, Integer> termLineGroupsPairs = new HashMap<>();
    List<TreeSet<Integer>> lineNumGroups = new ArrayList<>();

    for (int lineNum = 0; lineNum < lines.size(); lineNum++) {
        String line = lines.get(lineNum);
        String[] lineElements = line.replaceAll("\"", "").replaceAll(" ", "").split(";");
        Set<String> termSet = new HashSet<>(Arrays.asList(lineElements));
        termSet.remove("");

        Integer groupNum = null;
        TreeSet<String> tempSet = new TreeSet<>(termLineGroupsPairs.keySet());
        tempSet.retainAll(termSet); //оставляем только общие элементы
        if (!tempSet.isEmpty()) {
            String term = tempSet.first();
            groupNum = termLineGroupsPairs.get(term);
            lineNumGroups.get(groupNum).add(lineNum);
        }

        if (groupNum == null) {
            TreeSet<Integer> group = new TreeSet<>();
            group.add(lineNum);
            lineNumGroups.add(group);
            groupNum = lineNumGroups.size() - 1;
        }
        for (String term : termSet) {
            termLineGroupsPairs.put(term, groupNum);
        }
        if (lineNumGroups.size() % 1000 == 0)
            System.out.println(lineNumGroups.size());
    }

    resultSet.addAll(lineNumGroups);
    return resultSet;
}

而且我所有的解决方案都工作太久(我试图以不同的方式解决这个问题)。诚然,如果少于一千行,那么它可以快速运行(我符合指定的限制),并且几乎可以使用我的任何算法。

请告诉我如何解决这个问题(或在我的解决方案中进行哪些更改以使其快速运行)。

java
  • 2 个回答
  • 10 Views
Martin Hope
Max Lich
Asked: 2020-07-18 20:22:30 +0000 UTC

Adapter、Decorator、Wrapper 和 Proxy 模式之间的区别和相似之处是什么?

  • 11

你好。我是用设计模式一点点了解的,看不懂这些模式的区别。在某些地方,它们被认为是同义词。我好像发现了adapter和decorator的区别(按我的理解,第一个实现的接口与被包装对象的接口不同;而第二个实现的是与被包装对象相同的接口)。但是我找不到适配器与说唱歌手(包装器)有何不同。也不清楚代理与装饰器有何不同。PS 代码示例需要立即看到差异和相似之处。

java
  • 2 个回答
  • 10 Views
Martin Hope
Max Lich
Asked: 2020-05-04 17:21:16 +0000 UTC

什么是监视器、互斥量和信号量?是相同的还是不同的东西?

  • 16

只是写的不一样。我只是无法理解这些概念中的每一个实际上意味着什么。例如,同一个 Eckel 有这样的诗句:

为了解决线程争用问题,几乎所有的多线程方案都同步访问共享资源。这意味着一次只有一个线程可以访问共享资源。大多数情况下,这是通过将一段代码放在阻塞部分来完成的,这样一次只有一个线程可以遍历这段代码。由于这样的加锁提议具有互斥的效果,所以这种机制常被称为互斥(MUTual Exclusion)。

Java 以同步关键字的形式内置了对冲突预防的支持。当线程希望执行一段由同步字保护的代码时,它会检查信号量是否可用,访问信号量,执行代码,然后释放信号量。

我自己在一篇文章中读到(并且仍然坚持这种理解),互斥量是与 Java 中的每个对象相关联的对象,并且可以有两种状态:忙碌和空闲。而关于监视器在同一篇文章中写道,这是一种特殊的机制(实际上是一段代码),它使用互斥锁来调节线程对某个代码块(即,它负责捕获一个资源线程,并且只允许一个给定的线程(捕获互斥锁)遍历监视器保护的给定代码块;因此,监视器不允许其他线程占用该资源,并且这个代码块;当线程退出此代码块时,监视器释放互斥量并允许其他线程进入此代码块)。这是正确的理解吗?

这些概念在 Java 中究竟意味着什么?

java
  • 1 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5