javax.ws.rs.ProcessingException,在 Payara Server 5 中找不到内容类型 application/json 类型的 writer

2024-01-28

first Sorry for my bulky source code and simple question.

我收到这个错误。

javax.ws.rs.ProcessingException:RESTEASY003215:找不到内容类型应用程序/json类型的编写器:com.acme.customers.lib.v1.Customer

完整跟踪:

--- exec-maven-plugin:1.5.0:exec (default-cli) @ acme-customers-api ---
Exception in thread "main" javax.ws.rs.ProcessingException: RESTEASY004655: Unable to invoke request: javax.ws.rs.ProcessingException: RESTEASY003215: could not find writer for content-type application/json type: com.acme.customers.lib.v1.Customer
    at org.jboss.resteasy.client.jaxrs.engines.ManualClosingApacheHttpClient43Engine.invoke(ManualClosingApacheHttpClient43Engine.java:287)
    at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.invoke(ClientInvocation.java:488)
    at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.invoke(ClientInvocation.java:65)
    at org.jboss.resteasy.client.jaxrs.internal.ClientInvocationBuilder.post(ClientInvocationBuilder.java:226)
    at com.acme.customers.api.rest.v1.test.ConsumingServices.main(ConsumingServices.java:67)
Caused by: javax.ws.rs.ProcessingException: RESTEASY003215: could not find writer for content-type application/json type: com.acme.customers.lib.v1.Customer
    at org.jboss.resteasy.core.interception.jaxrs.ClientWriterInterceptorContext.throwWriterNotFoundException(ClientWriterInterceptorContext.java:50)
    at org.jboss.resteasy.core.interception.jaxrs.AbstractWriterInterceptorContext.getWriter(AbstractWriterInterceptorContext.java:302)
    at org.jboss.resteasy.core.interception.jaxrs.AbstractWriterInterceptorContext.syncProceed(AbstractWriterInterceptorContext.java:240)
    at org.jboss.resteasy.core.interception.jaxrs.AbstractWriterInterceptorContext.proceed(AbstractWriterInterceptorContext.java:224)
    at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.writeRequestBody(ClientInvocation.java:440)
    at org.jboss.resteasy.client.jaxrs.engines.ManualClosingApacheHttpClient43Engine.writeRequestBodyToOutputStream(ManualClosingApacheHttpClient43Engine.java:589)
    at org.jboss.resteasy.client.jaxrs.engines.ManualClosingApacheHttpClient43Engine.buildEntity(ManualClosingApacheHttpClient43Engine.java:548)
    at org.jboss.resteasy.client.jaxrs.engines.ManualClosingApacheHttpClient43Engine.loadHttpMethod(ManualClosingApacheHttpClient43Engine.java:455)
    at org.jboss.resteasy.client.jaxrs.engines.ManualClosingApacheHttpClient43Engine.invoke(ManualClosingApacheHttpClient43Engine.java:265)
    ... 4 more
Command execution failed.
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
    at org.apache.commons.exec.DefaultExecutor.executeInternal (DefaultExecutor.java:404)
    at org.apache.commons.exec.DefaultExecutor.execute (DefaultExecutor.java:166)
    at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:764)
    at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:711)
    at org.codehaus.mojo.exec.ExecMojo.execute (ExecMojo.java:289)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time:  5.277 s
Finished at: 2020-09-03T10:55:26-05:00
------------------------------------------------------------------------
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.5.0:exec (default-cli) on project acme-customers-api: Command execution failed.: Process exited with an error: 1 (Exit value: 1) -> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

使用带有 URL 的 Postmanhttp://localhost:8080/api/v1/customers/createPurchaser

With the Header enter image description here

My ConsumingServices类是

import java.util.Date;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.Invocation;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.ClientProperties;

public class ConsumingServices {

    public static void main(String[] args) {
        Customer customer = new Customer();
        customer.setFirstName("John");
        customer.setLastName("Mason");
        customer.setEmail("[email protected] /cdn-cgi/l/email-protection");
        customer.setDateOfBirth(new Date());
        customer.setStatus(CustomerStatus.ACTIVE);

        ClientConfig configuration = new ClientConfig();
        configuration.property(ClientProperties.CONNECT_TIMEOUT, 1000);
        configuration.property(ClientProperties.READ_TIMEOUT, 1000);
        Client client = ClientBuilder.newClient(configuration);

        WebTarget target = client.target("http://localhost:8080/api/v1/customers");

        Invocation.Builder invocationBuilder = target.path("createPurchaser")
                .request(MediaType.APPLICATION_JSON)
                .accept(MediaType.APPLICATION_JSON);

        Response response = invocationBuilder
                .header("Authorization", "1234")
                .post(Entity.entity(customer, MediaType.APPLICATION_JSON));

        if (response.getStatus() == Response.Status.OK.getStatusCode()) {
            Purchaser purchaser = response.readEntity(Purchaser.class);
            System.out.println("purchaser:".concat(purchaser.toString()));
        } else {
            if (MediaType.TEXT_PLAIN_TYPE.equals(response.getMediaType())) {
                String message = response.readEntity(String.class);
                System.out.println("message:" + message);
            } else if (MediaType.APPLICATION_JSON.equals(response.getMediaType())) {
                ApiError apiError = response.readEntity(ApiError.class);
                System.out.println("apiError:".concat(apiError.toString()));
            } else {
                System.out.println("response.getMediaType():" + response.getMediaType());
                String content = response.readEntity(String.class);
                System.out.println("message:" + content);
            }
        }
    }
}

例外的行是.post(Entity.entity(customer, MediaType.APPLICATION_JSON));

我的依赖项pom.xml are

<dependencies>
    <dependency>
        <groupId>com.acme</groupId>
        <artifactId>acme-customers-lib</artifactId>
        <version>${project.version}</version>
    </dependency>

    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
    </dependency>
    
    <dependency>
        <groupId>fish.payara.extras</groupId>
        <artifactId>payara-embedded-web</artifactId>
    </dependency>
    
    <dependency>
        <groupId>com.fasterxml.jackson.jaxrs</groupId>
        <artifactId>jackson-jaxrs-json-provider</artifactId>
    </dependency>
    
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
    </dependency>

    <!-- https://mvnrepository.com/artifact/javax/javaee-web-api -->
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-web-api</artifactId>
        <version>8.0.1</version>
        <scope>provided</scope>
    </dependency>
    
    <dependency>
        <groupId>javax.ws.rs</groupId>
        <artifactId>javax.ws.rs-api</artifactId>
    </dependency>
    
    <!-- https://mvnrepository.com/artifact/org.glassfish.jersey.core/jersey-client -->
    <dependency>
        <groupId>org.glassfish.jersey.core</groupId>
        <artifactId>jersey-client</artifactId>
        <version>2.31</version>
    </dependency>
    
    <!-- https://mvnrepository.com/artifact/org.jboss.resteasy/jaxrs-api -->
    <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>jaxrs-api</artifactId>
        <version>3.0.12.Final</version>
    </dependency>
    
    <!-- https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-client -->
    <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-client</artifactId>
        <version>4.5.6.Final</version>
    </dependency>
    
    <!-- https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-jaxrs -->
    <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-jaxrs</artifactId>
        <version>3.13.0.Final</version>
    </dependency>
    
    <!-- https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-jaxb-provider -->
    <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-jaxb-provider</artifactId>
        <version>4.5.6.Final</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-jackson2-provider -->
    <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-jackson2-provider</artifactId>
        <version>4.5.6.Final</version>
    </dependency>
    
    <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.11.2</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/javax.xml.bind/jaxb-api -->
    <dependency>
        <groupId>javax.xml.bind</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.3.1</version>
    </dependency>

</dependencies>

问题:我该如何解决这个异常?

我的课程代码......

The CustomerResource class

@Path("/customers")
@ApplicationScoped
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class CustomerResource {
    @POST
    @Path("/createPurchaser")
    public Response createPurchaser(Customer customer) {
        return Response
            .status(Response.Status.OK)
            .entity(customerService.createPurchaser(customer))
            .type(MediaType.APPLICATION_JSON)
            .build();
    }
}

The CustomerService界面

public interface CustomerService {

    Purchaser createPurchaser(Customer customer);
}

The createPurchaser的方法CustomerServiceImpl class

@ApplicationScoped
public class CustomerServiceImpl implements CustomerService {

    @Override
    public Purchaser createPurchaser(Customer customer) {

        if (customer == null) {
            throw new EmptyPayloadException(Customer.class.getSimpleName());
        }
        
        Purchaser client = new Purchaser();
        
        client.setFirstName(customer.getFirstName());
        client.setLastName(customer.getLastName());
        client.setAffiliationDate(new Date());
        client.setCustomerStatus(CustomerStatus.ACTIVE);
        client.setPurchaserDocument(new PurchaserDocument());
        client.getPurchaserDocument().setDateOfBirth(customer.getDateOfBirth());
        client.getPurchaserDocument().setNumberDocument(new Random().nextLong());
        client.getPurchaserDocument().setTypeDocument("CC");
        return client;
    }
}

The Customer class

import java.io.Serializable;
import java.util.Date;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
public class Customer extends BaseType implements Serializable {

    private String firstName;
    private String lastName;
    private CustomerStatus status;
    private String email;
    private Date dateOfBirth;

    public String getFirstName() {
        return firstName;
    }
    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }
    public String getLastName() {
        return lastName;
    }
    public void setLastName(String lastName) {
        this.lastName = lastName;
    }
    public CustomerStatus getStatus() {
        return status;
    }
    public void setStatus(CustomerStatus status) {
        this.status = status;
    }
    public String getEmail() {
        return email;
    }
    public void setEmail(String email) {
        this.email = email;
    }
    public Date getDateOfBirth() {
        return dateOfBirth;
    }
    public void setDateOfBirth(Date dateOfBirth) {
        this.dateOfBirth = dateOfBirth;
    }
}

Now the BaseType class

import java.util.Date;
public class BaseType {

    private String id;
    private Date createdAt;
    private Date updatedAt;

    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public Date getCreatedAt() {
        return createdAt;
    }
    public void setCreatedAt(Date createdAt) {
        this.createdAt = createdAt;
    }
    public Date getUpdatedAt() {
        return updatedAt;
    }
    public void setUpdatedAt(Date updatedAt) {
        this.updatedAt = updatedAt;
    }
}

the CustomerStatus enum

public enum CustomerStatus {
    ACTIVE, INACTIVE
}

The Purchaser class

import java.io.Serializable;
import java.util.Date;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
public class Purchaser implements Serializable {

    private String firstName;
    private String lastName;
    private Date affiliationDate;
    private CustomerStatus customerStatus;
    private PurchaserDocument purchaserDocument;

    public String getFirstName() {
        return firstName;
    }
    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }
    public String getLastName() {
        return lastName;
    }
    public void setLastName(String lastName) {
        this.lastName = lastName;
    }
    public Date getAffiliationDate() {
        return affiliationDate;
    }
    public void setAffiliationDate(Date affiliationDate) {
        this.affiliationDate = affiliationDate;
    }
    public CustomerStatus getCustomerStatus() {
        return customerStatus;
    }
    public void setCustomerStatus(CustomerStatus customerStatus) {
        this.customerStatus = customerStatus;
    }
    public PurchaserDocument getPurchaserDocument() {
        return purchaserDocument;
    }
    public void setPurchaserDocument(PurchaserDocument purchaserDocument) {
        this.purchaserDocument = purchaserDocument;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("Purchaser{firstName=").append(firstName);
        sb.append(", lastName=").append(lastName);
        sb.append(", affiliationDate=").append(affiliationDate);
        sb.append(", customerStatus=").append(customerStatus);
        sb.append(", purchaserDocument=").append(purchaserDocument);
        sb.append('}');
        return sb.toString();
    }
}

The PurchaserDocument class

import java.io.Serializable;
import java.util.Date;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
public class PurchaserDocument implements Serializable {

    private String typeDocument;
    private Long numberDocument;
    private Date dateOfBirth;

    public String getTypeDocument() {
        return typeDocument;
    }
    public void setTypeDocument(String typeDocument) {
        this.typeDocument = typeDocument;
    }
    public Long getNumberDocument() {
        return numberDocument;
    }
    public void setNumberDocument(Long numberDocument) {
        this.numberDocument = numberDocument;
    }
    public Date getDateOfBirth() {
        return dateOfBirth;
    }
    public void setDateOfBirth(Date dateOfBirth) {
        this.dateOfBirth = dateOfBirth;
    }

}

问题是jersey-client依赖性。您需要将其删除。原因:通用ClientBuilder is 建于always成为一个JerseyClientBuilder https://github.com/jax-rs/api/blob/master/jaxrs-api/src/main/java/javax/ws/rs/client/ClientBuilder.java#L94当 Jersey 客户端位于类路径上时。您拥有的 JSON 依赖项(自动向 RESTEast 客户端注册)resteasy-jackson2-provider用于RESTEasy。所以 Jersey 客户端不认识它。您可以手动向客户端注册提供程序,它应该可以工作。

client.register(JacksonJaxbJsonProvider.class);

但就像我说的,只需删除jersey-client and ClientBuilder会变成ResteasyClientBuilder并且它会识别resteasy-jackson2-provider并自动注册。除非你的目标is使用Jersey客户端,此时需要手动注册provider,或者添加Jersey自动注册依赖,即jersey-media-json-jackson.

Update

请注意,如果您计划在服务器环境中使用客户端,我刚刚注意到您正在使用 Payara,它在幕后使用 Jersey。所以服务器已经配备了所有 Jersey jars。如果您想使用 Jackson 作为您的提供者,您应该添加jersey-media-json-jackson并注册JacksonFeature与客户。如果您不这样做,它将默认使用 JSONB 作为 JSON 提供程序。如果你想使用RESTEasy,那么你可以忘记这一点。

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

javax.ws.rs.ProcessingException,在 Payara Server 5 中找不到内容类型 application/json 类型的 writer 的相关文章

  • 带路径压缩算法的加权 Quick-Union

    有一种 带路径压缩的加权快速联合 算法 代码 public class WeightedQU private int id private int iz public WeightedQU int N id new int N iz new
  • 使用 Tabula 通过 Python 读取 pdf 时出现 Java 错误

    我已经安装了 tabula 库 用于使用 python 将 pdf 读取到 pandas 数据框中 但是当我运行代码时 import tabula df tabula read pdf sample1 pdf pages 1 我得到了例外
  • 如何在由子控件组成的 SWT 复合材料上跟踪鼠标?

    我创建了自己的控件 我想跟踪鼠标并添加一个MouseTrackListener 很遗憾MouseEnter and MouseLeave当鼠标移动到我的合成部分 即标签和按钮 上时 也会生成事件 Mouse enter mouse ente
  • 如何在 JavaFX 中连接可观察列表?

    我所说的串联是指获得一个新列表 该列表侦听所有串联部分的更改 方法的目的是什么FXCollections concat ObservableList
  • 与 Eclipse 中的 Java Content Assist 交互

    作为我的插件项目的一部分 我正在考虑与 Eclipse 在 Java 文件上显示的内容辅助列表进行交互 我正在尝试根据一些外部数据对列表进行重新排序 我看过一些有关创建新内容辅助的教程 但没有看到有关更改现有内容辅助的教程 这可能吗 如果是
  • 为什么即使我的哈希码值相同,“==”也会返回 false

    我写了一个像这样的课程 public class HashCodeImpl public int hashCode return 1 public static void main String args TODO Auto generat
  • Java 中如何将 char 转换为 int? [复制]

    这个问题在这里已经有答案了 我是Java编程新手 我有例如 char x 9 我需要得到撇号中的数字 即数字 9 本身 我尝试执行以下操作 char x 9 int y int x 但没有成功 那么我应该怎么做才能得到撇号中的数字呢 ASC
  • 将非 Android 项目添加到 Android 项目

    我在 Eclipse 中有三个项目 Base Server 和 AndroidClient Base和Server是Java 1 7项目 而AndroidClient显然是一个android项目 基础项目具有在服务器和 Android 客户
  • 如何在java中将日期格式从YYMMDD更改为YYYY-MM-DD? [关闭]

    Closed 这个问题不符合堆栈溢出指南 help closed questions 目前不接受答案 我从机器可读代码中获取日期格式为 YYMMDD 如何将其更改为 YYYY MM DD 例如我收到 871223 YYMMDD 我想把它改成
  • Sun 在 EDT 之外做 GUI 工作的演示?

    我正在看SplashDemo java http download oracle com javase tutorial uiswing examples misc SplashDemoProject src misc SplashDemo
  • 如何在字段值无效的情况下更改 Struts2 验证错误消息?

    我在 Web 表单上使用 Struts2 验证 如果字段假设为整数或日期 则
  • Java Applet 中的 Apache FOP - 未找到数据的 ImagePreloader

    我正在研究成熟商业产品中的一个问题 简而言之 我们使用 Apache POI 库的一部分来读取 Word DOC 或 DOCX 文件 并将其转换为 XSL FO 以便我们可以进行标记替换 然后 我们使用嵌入到 Java 程序中的 FOP 将
  • Akka 与现有 java 项目集成的示例

    如果我已经有现有的javaWeb 应用程序使用spring and servlet容器 将 Akka 集成到其中的正确方法是什么 就像我将会有Actor1 and Actor2互相沟通的 开始使用这些演员的切入点是什么 例如 1 把它放在那
  • 在Java中运行bat文件并等待

    您可能会认为从 Java 启动 bat 文件是一项简单的任务 但事实并非如此 我有一个 bat 文件 它对从文本文件读取的值循环执行一些 sql 命令 它或多或少是这样的 FOR F x in CD listOfThings txt do
  • Eclipse 中的 Java EE 视角

    我有标准版的 eclipse Galileo 现在我想在上面开发企业应用程序 知道如何获得 Java EE 视角吗 标准版如何安装Java EE工具 我有同样的问题 我首先使用 Ubuntu 软件中心安装了最新的 Eclipse 平台 In
  • Hibernate 本机查询 - char(3) 列

    我在 Oracle 中有一个表 其中列 SC CUR CODE 是 CHAR 3 当我做 Query q2 em createNativeQuery select sc cur code sc amount from sector cost
  • Java 正则表达式中的逻辑 AND

    是否可以在 Java Regex 中实现逻辑 AND 如果答案是肯定的 那么如何实现呢 正则表达式中的逻辑 AND 由一系列堆叠的先行断言组成 例如 foo bar glarch 将匹配包含所有三个 foo bar 和 glarch 的任何
  • Java RMI - 客户端超时

    我正在使用 Java RMI 构建分布式系统 它必须支持服务器丢失 如果我的客户端使用 RMI 连接到服务器 如果该服务器出现故障 例如电缆问题 我的客户端应该会收到异常 以便它可以连接到其他服务器 但是当服务器出现故障时 我的客户端什么也
  • 由 Servlet 容器提供服务的 WebSocket

    上周我研究了 WebSockets 并对如何使用 Java Servlet API 实现服务器端进行了一些思考 我没有花费太多时间 但在使用 Tomcat 进行一些测试时遇到了以下问题 如果不修补容器或至少对 HttpServletResp
  • Java 和/C++ 在多线程方面的差异

    我读过一些提示 多线程实现很大程度上取决于您正在使用的目标操作系统 操作系统最终提供了多线程能力 比如Linux有POSIX标准实现 而windows32有另一种方式 但我想知道编程语言水平的主要不同 C似乎为同步提供了更多选择 例如互斥锁

随机推荐

  • 哈希迭代不返回子目录内容

    我有一个方法可以查找给定父目录的子目录 我将父目录存储在哈希中 然后将哈希作为参数传递 我试图将子目录的内容收集到一个数组中 然后将其输出到报告中 我遇到了一个问题 数组的内容仅将目录存储在哈希的最后一个值中 我很快意识到内容在循环的每次迭
  • NUnit 无法构建测试 - 未发现测试

    我正在研究selenium网络驱动程序项目 我能够在中构建测试Test Explorer并执行 重建解决方案时 我立即收到以下错误 Unit Adapter 3 2 0 0 Test discovery starting NUnit VS
  • 缩小 Octave / gnuplot

    我在 Windows 下使用 Octave 和 gnuplot 我可以使用鼠标右键进行放大 但如何缩小用户界面呢 I found 纳布尔上的这篇文章 http old nabble com zoom td16353082 html 紧迫p带
  • 向 UITableViewCell 添加边距

    I am trying to achieve a view I mocked out on sketch I ve replicated it on Android cause I m really good on that platfor
  • Delphi - Graphics32,绘制抗锯齿圆角矩形

    如何使用 Graphics32 绘制抗锯齿圆角矩形 我设法在 bitmap32 画布上使用 TPolygon 制作了一个普通矩形 但我找不到任何绘制圆角的参考 希望有一些代码 function GetRoundedFixedRectangl
  • 致命:提交时无法解析 HEAD 错误

    每当我尝试提交工作时 都会收到此错误 fatal could not parse HEAD 如果我想保留我的更改 该怎么办 你知道什么分行吗HEAD应该指向 是吗master Run git symbolic ref HEAD refs h
  • Concourse:通过 HTTP 请求触发作业

    我正在尝试使用 Git 服务器上的 Web 挂钩触发 Concourse 作业 按照此Github 上的问题 https github com concourse concourse issues 331我找到了一个端点定义 https g
  • 谁能告诉我为什么我的算法是错误的?

    我正在研究单源最短路径问题 我对 bfs 进行了修改 可以解决该问题 该算法运行时间为 O 2E 次 我只是不明白为什么它是错误的 一定是这样 否则 dijstra 不会是最有效的算法 def bfs modified G src des
  • Cocos2d 游戏中的碰撞检测?

    我正在尝试检测碰撞 of two sprites按照以下方式 但是当我尝试运行游戏时没有发生碰撞 我可能做错了什么 void update ccTime dt CGRect projectileRect CGRectMake project
  • MongoDB:启动期间无法设置套接字

    我有 Windows 8 1 Enterprise 64 位机器 我已经为 Windows 安装了带有 SSL 支持的 mongodb msi 我创建了环境设置所需的所有必要条件 现在使用命令提示符导航到 mongodb 安装文件夹中的 b
  • 取消订阅 Single 的正确方法是什么[重复]

    这个问题在这里已经有答案了 我想做一些短暂的延迟后 public void notifyMe Single timer 500 TimeUnit MILLISECONDS subscribeOn Schedulers io subscrib
  • Rails 3.2.13 recognize_path 返回约束的路由错误

    我的路线中有两条路径 相同的路径指向不同的控制器和操作 match id gt users show as gt user constraints gt UserConstraint match id gt customers show a
  • 无法使用 ARIMA 预测下一个值:输入包含 NaN、无穷大或对于 dtype('float64') 来说太大的值

    我有以下代码片段 import pmdarima as pmd ts 3 86 5 52 68 14 20 12 22 4 2 model pmd auto arima ts start p 1 start q 1 test adf est
  • DTMF Goertzel 算法不起作用

    因此 我正在打开我在 audacity 中生成的 DTMF 音调的 raw 文件 我抓住了一个类似于维基百科文章中的罐装 goertzel 算法 但它似乎无法解码正确的数字 解码后的数字也会根据我传递给算法的 N 值而变化 据我了解 较高的
  • 生成随机数的div

    我无法让脚本创建随机数量的 div 在这个具体示例中 介于 5 和 20 之间 问题可能出在 for 循环中 生成随机数的函数在随机颜色函数下面正常工作 我猜由于某些原因它没有被识别 另外我在萤火虫中没有收到任何错误 Example fun
  • 调用 addAction 时删除通知?

    我在通知中添加了两个操作按钮 当我单击其中任何一个时 它们会执行所需的操作 但通知仍保留在我的通知抽屉中 我知道单击操作按钮时可以从通知抽屉中删除通知 因为这就是 Gmail 的功能 如果我单击主通知 它将打开应用程序并从通知抽屉中删除通知
  • 课程。重点是什么?

    我对 PHP 中的 OOP 相当陌生 我编写了几个基本脚本 但没有什么令人印象深刻的 我真正从中得到的只是 制作一组函数可能会更容易 include them 类的结构似乎只是混淆了原本简单的过程 将所有内容整理到一个类中并没有真正添加任何
  • 如何从文件中提取文本行?

    我有一个充满文件的目录 我需要从中提取页眉和页脚 它们的长度都是可变的 因此使用头部或尾部是行不通的 每个文件都有一行我可以搜索 但我不想在结果中包含该行 通常是 Start more text here 并结束于 Finish more
  • elixir+hex - ranch_proxy_protocol ssl:ssl_accept 3 已弃用,出现十六进制错误

    enter code here我正在以下命令运行 mix ecto create mix ecto migrate 这给出了一个错误 gt Compiling ranch proxy protocol gt Compiling src ra
  • javax.ws.rs.ProcessingException,在 Payara Server 5 中找不到内容类型 application/json 类型的 writer

    first Sorry for my bulky source code and simple question 我收到这个错误 javax ws rs ProcessingException RESTEASY003215 找不到内容类型应