Web 服务面试问题 - SOAP、RESTful

2023-11-07

欢迎来到 Web 服务面试问题及其详细答案。最近我写了很多关于 Web 服务的文章。我们如何用 Java 创建 SOAP 和 RESTful Web 服务。

Web 服务面试问题

web services interview questions, restful web services interview questions, rest interview questions, soap interview questions Here I am providing you a list of web services interview questions to help you in interview. First of all there are generic questions for web services concept since it’s not technology or language specific and then we have java web services interview questions.

  1. 什么是网络服务?

  2. Web 服务有哪些优点?

  3. Web 服务有哪些不同类型?

  4. 什么是 SOAP?

  5. SOAP Web 服务有哪些优点?

  6. SOAP Web 服务有哪些缺点?

  7. 什么是 WSDL?

  8. WSDL 有哪些不同的组件?

  9. 什么是UDDI?

  10. SOAP Web 服务中自上而下和自下而上的方法有什么区别?

  11. 什么是 REST Web 服务?

  12. REST Web 服务有哪些优势?

  13. REST Web 服务有哪些缺点?

  14. Restful Web 服务中的资源是什么?

  15. Restful Web 服务支持哪些不同的 HTTP 方法?

  16. 比较 SOAP 和 REST Web 服务?

  17. 测试 Web 服务有哪些不同的方法?

  18. 我们可以在 Web 服务中维护用户会话吗?

  19. SOA 和 Web 服务有什么区别?

  20. HTTP 请求中 Accept 和 Content-Type 标头有什么用?

  21. 您将如何在 SOAP 和 REST Web 服务之间进行选择?

  22. 什么是 JAX-WS API?

  23. 能否说出一些 Java 框架来实现 SOAP Web 服务?

  24. JAX-WS API 中使用的重要注释的名称?

  25. 有什么用javax.xml.ws.Endpoint class?

  26. RPC 样式和文档样式 SOAP Web 服务有什么区别?

  27. 如何获取 SOAP Web 服务的 WSDL 文件?

  28. 什么是 sun-jaxws.xml 文件?

  29. 什么是 JAX-RS API?

  30. 列出 JAX-RS API 的一些实现?

  31. wsimport 实用程序是什么?

  32. JAX-RS API 中使用的重要注释的名称?

  33. @XmlRootElement 注解有什么用?

  34. 如何在HTTP响应中设置不同的状态码?

  35. 什么是网络服务?

    Web 服务采用客户端-服务器模型,其中客户端应用程序可以通过网络访问 Web 服务。 Web 服务提供端点 URL 并公开可以通过用 java、shell 脚本或任何其他不同技术编写的客户端程序通过网络访问的方法。 Web 服务是无状态的,并且不会像 Web 应用程序那样维护用户会话。

  36. Web 服务有哪些优点?

    Web 服务的一些优点是:

    • 互操作性:Web服务可以通过网络访问,运行在HTTP/SOAP协议上,使用XML/JSON来传输数据,因此可以用任何编程语言进行开发。 Web服务可以用java编程编写,客户端可以用PHP编写,反之亦然。
    • 可重用性:一个 Web 服务可以同时被多个客户端应用程序使用。
    • 松耦合:Web 服务客户端代码与服务器代码完全独立,因此我们在应用程序中实现了松耦合。
    • 易于部署和集成,就像 Web 应用程序一样。
    • 多个服务版本可以同时运行。
  37. Web 服务有哪些不同类型?

    Web 服务有两种类型:

    1. SOAP Web 服务:运行在 SOAP 协议上并使用 XML 技术发送数据。
    2. Restful Web Services:这是一种架构风格,几乎一直运行在 HTTP/HTTPS 协议上。 REST 是一种无状态的客户端-服务器架构,其中 Web 服务是资源,可以通过其 URI 进行识别。客户端应用程序可以使用 HTTP GET/POST 方法来调用 Restful Web 服务。
  38. 什么是 SOAP?

    SOAP 代表简单对象访问协议。 SOAP 是一种基于 XML 的行业标准协议,用于设计和开发 Web 服务。由于它基于 XML,因此它独立于平台和语言。所以我们的服务器可以基于JAVA,客户端可以基于.NET、PHP等,反之亦然。

  39. SOAP Web 服务有哪些优点?

SOAP web services have all the advantages that web services has, some of the additional advantages are:
-   WSDL document provides contract and technical details of the web services for client applications without exposing the underlying implementation technologies.
-   SOAP uses XML data for payload as well as contract, so it can be easily read by any technology.
-   SOAP protocol is universally accepted, so it's an industry standard approach with many easily available open source implementations.
  1. SOAP Web 服务有哪些缺点?

Some of the disadvantages of SOAP protocol are:
-   Only XML can be used, JSON and other lightweight formats are not supported.
-   SOAP is based on the contract, so there is a tight coupling between client and server applications.
-   SOAP is slow because payload is large for a simple string message, since it uses XML format.
-   Anytime there is change in the server side contract, client stub classes need to be generated again.
-   Can't be tested easily in browser
  1. 什么是 WSDL?

WSDL stands for Web Service Description Language. WSDL is an XML based document that provides technical details about the web service. Some of the useful information in WSDL document are: method name, port types, service end point, binding, method parameters etc.
  1. WSDL 有哪些不同的组件?

Some of the different tags in WSDL xml are:
-   xsd:import namespace and schemaLocation: provides WSDL URL and unique namespace for web service.
-   message: for method arguments
-   part: for method argument name and type
-   portType: service name, there can be multiple services in a wsdl document.
-   operation: contains method name
-   soap:address for endpoint URL.
  1. 什么是UDDI?

UDDI is acronym for Universal Description, Discovery and Integration. UDDI is a directory of web services where client applications can lookup for web services. Web Services can register to the UDDI server and make them available to client applications.
  1. SOAP Web 服务中自上而下和自下而上的方法有什么区别?

In Top Down approach first WSDL document is created to establish the contract between web service and client and then code is written, it's also termed as contract first approach. This is hard to implement because classes need to be written to confirm the contract established in WSDL. Benefit of this approach is that both client and server code can be written in parallel. In Bottom Up approach, first web service code is written and then WSDL is generated. It's also termed as contract last approach. This approach is easy to implement because WSDL is generated based on code. In this approach client code have to wait for WSDL from server side to start their work.
  1. 什么是 REST Web 服务?

REST is the acronym for REpresentational State Transfer. REST is an architectural style for developing applications that can be accessed over the network. REST architectural style was brought in light by Roy Fielding in his doctoral thesis in 2000. REST is a stateless client-server architecture where web services are resources and can be identified by their URIs. Client applications can use HTTP GET/POST methods to invoke Restful web services. REST doesn’t specify any specific protocol to use, but in almost all cases it’s used over HTTP/HTTPS. When compared to SOAP web services, these are lightweight and doesn’t follow any standard. We can use XML, JSON, text or any other type of data for request and response.
  1. REST Web 服务有哪些优势?

Some of the advantages of REST web services are:
-   Learning curve is easy since it works on HTTP protocol
-   Supports multiple technologies for data transfer such as text, xml, json, image etc.
-   No contract defined between server and client, so loosely coupled implementation.
-   REST is a lightweight protocol
-   REST methods can be tested easily over browser.
  1. REST Web 服务有哪些缺点?

Some of the disadvantages of REST are:
-   Since there is no contract defined between service and client, it has to be communicated through other means such as documentation or emails.
-   Since it works on HTTP, there can't be asynchronous calls.
-   Sessions can't be maintained.
  1. Restful Web 服务中的资源是什么?

Resource is the fundamental concept of Restful architecture. A resource is an object with a type, relationship with other resources and methods that operate on it. Resources are identified with their URI, HTTP methods they support and request/response data type and format of data.
  1. Restful Web 服务支持哪些不同的 HTTP 方法?

Restful web services supported HTTP methods are - GET, POST, PUT, DELETE and HEAD.
  1. 比较 SOAP 和 REST Web 服务?

<!--
<style>.tg {border-collapse:collapse;border-spacing:0;border-color:#999;} .tg td{font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:#999;color:#444;background-color:#F7FDFA;} .tg th{font-family:Arial, sans-serif;font-size:14px;font-weight:normal;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:#999;color:#fff;background-color:#26ADE4;} .tg .tg-baqh{text-align:center;vertical-align:top} .tg .tg-6k2t{background-color:#D2E4FC;vertical-align:top} .tg .tg-yw4l{vertical-align:top}</style>
-->

| SOAP | REST  
 |
| --- | --- |
| SOAP is a standard protocol for creating web services.  
 | REST is an architectural style to create web services.  
 |
| SOAP is acronym for Simple Object Access Protocol. | REST is acronym for REpresentational State Transfer. |
| SOAP uses WSDL to expose supported methods and technical details.  
 | REST exposes methods through URIs, there are no technical details.  
 |
| SOAP web services and client programs are bind with WSDL contract  
 | REST doesn't have any contract defined between server and client  
 |
| SOAP web services and client are tightly coupled with contract.  
 | REST web services are loosely coupled.  
 |
| SOAP learning curve is hard, requires us to learn about WSDL generation, client stubs creation etc.  
 | REST learning curve is simple, POJO classes can be generated easily and works on simple HTTP methods.  
 |
| SOAP supports XML data format only  
 | REST supports any data type such as XML, JSON, image etc.  
 |
| SOAP web services are hard to maintain, any change in WSDL contract requires us to create client stubs again and then make changes to client code.  
 | REST web services are easy to maintain when compared to SOAP, a new method can be added without any change at client side for existing resources.  
 |
| SOAP web services can be tested through programs or software such as Soap UI.  
 | REST can be easily tested through CURL command, Browsers and extensions such as Chrome Postman.  
 |
  1. 测试 Web 服务有哪些不同的方法?

SOAP web services can be tested programmatically by generating client stubs from WSDL or through software such as Soap UI. REST web services can be tested easily with program, curl commands and through browser extensions. Resources supporting GET method can be tested with browser itself, without any program.
  1. 我们可以在 Web 服务中维护用户会话吗?

Web services are stateless so we can't maintain user sessions in web services.
  1. SOA 和 Web 服务有什么区别?

Service Oriented Architecture (SOA) is an architectural pattern where applications are designed in terms of services that can be accessed through communication protocol over network. SOA is a design pattern and doesn't go into implementation. Web Services can be thought of as Services in SOAP architecture and providing means to implement SOA pattern.
  1. HTTP 请求中 Accept 和 Content-Type 标头有什么用?

These are important headers in Restful web services. Accept headers tells web service what kind of response client is accepting, so if a web service is capable of sending response in XML and JSON format and client sends Accept header as "application/xml" then XML response will be sent. For Accept header "application/json", server will send the JSON response. Content-Type header is used to tell server what is the format of data being sent in the request. If Content-Type header is "application/xml" then server will try to parse it as XML data. This header is useful in HTTP Post and Put requests.
  1. 您将如何在 SOAP 和 REST Web 服务之间进行选择?

Web Services work on client-server model and when it comes to choose between SOAP and REST, it all depends on project requirements. Let's look at some of the conditions affecting our choice:
-   Do you know your web service clients beforehand? If Yes, then you can define a contract before implementation and SOAP seems better choice. But if you don't then REST seems better choice because you can provide sample request/response and test cases easily for client applications to use later on.
-   How much time you have? For quick implementation REST is the best choice. You can create web service easily, test it through browser/curl and get ready for your clients.
-   What kind of data format are supported? If only XML then you can go with SOAP but if you think about supporting JSON also in future then go with REST.
  1. 什么是 JAX-WS API?

JAX-WS stands for Java API for XML Web Services. JAX-WS is XML based Java API to build web services server and client application. It’s part of standard Java API, so we don’t need to include anything else which working with it. Refer to [JAX-WS Tutorial](/community/tutorials/jax-ws-tutorial) for a complete example.
  1. 能否说出一些 Java 框架来实现 SOAP Web 服务?

We can create SOAP web services using JAX-WS API, however some of the other frameworks that can be used are Apache Axis and Apache CXF. Note that they are not implementations of JAX-WS API, they are totally different framework that work on Servlet model to expose your business logic classes as SOAP web services. Read more at [Java SOAP Web Service Eclipse](/community/tutorials/soap-webservices-in-java-example-eclipse) example.
  1. JAX-WS API 中使用的重要注释的名称?

Some of the important annotations used in JAX-WS API are:
-   @WebService
-   @SOAPBinding
-   @WebMethod
  1. 有什么用javax.xml.ws.Endpoint class?

Endpoint class provides useful methods to create endpoint and publish existing implementation as web service. This comes handy in testing web services before making further changes to deploy it on actual server.
  1. RPC 样式和文档样式 SOAP Web 服务有什么区别?

RPC style generate WSDL document based on the method name and it's parameters. No type definitions are present in WSDL document. Document style contains type and can be validated against predefined schema. Let's look at these with a simple program. Below is a simple test program where I am using Endpoint to publish my simple SOAP web service. `TestService.java`

```
package com.journaldev.jaxws.service;

import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.xml.ws.Endpoint;

@WebService
@SOAPBinding(style = SOAPBinding.Style.RPC)
public class TestService {

	@WebMethod
	public String sayHello(String msg){
		return "Hello "+msg;
	}
	
	public static void main(String[] args){
		Endpoint.publish("https://localhost:8888/testWS", new TestService());
	}
}
```

When I run above program and then access the WSDL, it gives me below XML. `rpc.xml`

```
<?xml version='1.0' encoding='UTF-8'?>
<!-- Published by JAX-WS RI (https://jax-ws.java.net). RI's version is JAX-WS RI 2.2.10 svn-revision#919b322c92f13ad085a933e8dd6dd35d4947364b. --><!-- Generated by JAX-WS RI (https://jax-ws.java.net). RI's version is JAX-WS RI 2.2.10 svn-revision#919b322c92f13ad085a933e8dd6dd35d4947364b. -->
<definitions xmlns:wsu="https://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="https://www.w3.org/ns/ws-policy" xmlns:wsp1_2="https://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="https://www.w3.org/2007/05/addressing/metadata" xmlns:soap="https://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="https://service.jaxws.journaldev.com/" xmlns:xsd="https://www.w3.org/2001/XMLSchema" xmlns="https://schemas.xmlsoap.org/wsdl/" targetNamespace="https://service.jaxws.journaldev.com/" name="TestServiceService">
<types/>
<message name="sayHello">
<part name="arg0" type="xsd:string"/>
</message>
<message name="sayHelloResponse">
<part name="return" type="xsd:string"/>
</message>
<portType name="TestService">
<operation name="sayHello">
<input wsam:Action="https://service.jaxws.journaldev.com/TestService/sayHelloRequest" message="tns:sayHello"/>
<output wsam:Action="https://service.jaxws.journaldev.com/TestService/sayHelloResponse" message="tns:sayHelloResponse"/>
</operation>
</portType>
<binding name="TestServicePortBinding" type="tns:TestService">
<soap:binding transport="https://schemas.xmlsoap.org/soap/http" style="rpc"/>
<operation name="sayHello">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal" namespace="https://service.jaxws.journaldev.com/"/>
</input>
<output>
<soap:body use="literal" namespace="https://service.jaxws.journaldev.com/"/>
</output>
</operation>
</binding>
<service name="TestServiceService">
<port name="TestServicePort" binding="tns:TestServicePortBinding">
<soap:address location="https://localhost:8888/testWS"/>
</port>
</service>
</definitions>
```

Notice that **types** element is empty and we can't validate it against any schema. Now just change the `SOAPBinding.Style.RPC` to `SOAPBinding.Style.DOCUMENT` and you will get below WSDL. `document.xml`

```
<?xml version='1.0' encoding='UTF-8'?>
<!-- Published by JAX-WS RI (https://jax-ws.java.net). RI's version is JAX-WS RI 2.2.10 svn-revision#919b322c92f13ad085a933e8dd6dd35d4947364b. --><!-- Generated by JAX-WS RI (https://jax-ws.java.net). RI's version is JAX-WS RI 2.2.10 svn-revision#919b322c92f13ad085a933e8dd6dd35d4947364b. -->
<definitions xmlns:wsu="https://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="https://www.w3.org/ns/ws-policy" xmlns:wsp1_2="https://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="https://www.w3.org/2007/05/addressing/metadata" xmlns:soap="https://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="https://service.jaxws.journaldev.com/" xmlns:xsd="https://www.w3.org/2001/XMLSchema" xmlns="https://schemas.xmlsoap.org/wsdl/" targetNamespace="https://service.jaxws.journaldev.com/" name="TestServiceService">
<types>
<xsd:schema>
<xsd:import namespace="https://service.jaxws.journaldev.com/" schemaLocation="https://localhost:8888/testWS?xsd=1"/>
</xsd:schema>
</types>
<message name="sayHello">
<part name="parameters" element="tns:sayHello"/>
</message>
<message name="sayHelloResponse">
<part name="parameters" element="tns:sayHelloResponse"/>
</message>
<portType name="TestService">
<operation name="sayHello">
<input wsam:Action="https://service.jaxws.journaldev.com/TestService/sayHelloRequest" message="tns:sayHello"/>
<output wsam:Action="https://service.jaxws.journaldev.com/TestService/sayHelloResponse" message="tns:sayHelloResponse"/>
</operation>
</portType>
<binding name="TestServicePortBinding" type="tns:TestService">
<soap:binding transport="https://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="sayHello">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="TestServiceService">
<port name="TestServicePort" binding="tns:TestServicePortBinding">
<soap:address location="https://localhost:8888/testWS"/>
</port>
</service>
</definitions>
```

Open schemaLocation URL in browser and you will get below XML. `schemaLocation.xml`

```
<?xml version='1.0' encoding='UTF-8'?>
<!-- Published by JAX-WS RI (https://jax-ws.java.net). RI's version is JAX-WS RI 2.2.10 svn-revision#919b322c92f13ad085a933e8dd6dd35d4947364b. -->
<xs:schema xmlns:tns="https://service.jaxws.journaldev.com/" xmlns:xs="https://www.w3.org/2001/XMLSchema" version="1.0" targetNamespace="https://service.jaxws.journaldev.com/">

<xs:element name="sayHello" type="tns:sayHello"/>

<xs:element name="sayHelloResponse" type="tns:sayHelloResponse"/>

<xs:complexType name="sayHello">
<xs:sequence>
<xs:element name="arg0" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>

<xs:complexType name="sayHelloResponse">
<xs:sequence>
<xs:element name="return" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
```

So here WSDL document can be validated against the schema definintion.
  1. 如何获取 SOAP Web 服务的 WSDL 文件?

WSDL document can be accessed by appending ?wsdl to the SOAP endoint URL. In above example, we can access it at `https://localhost:8888/testWS?wsdl` location.
  1. 什么是 sun-jaxws.xml 文件?

This file is used to provide endpoints details when JAX-WS web services are deployed in servlet container such as Tomcat. This file is present in WEB-INF directory and contains endpoint name, implementation class and URL pattern. For example; `sun-jaxws.xml`

```
<?xml version="1.0" encoding="UTF-8"?>
<endpoints xmlns="https://java.sun.com/xml/ns/jax-ws/ri/runtime" version="2.0">
  <endpoint
     name="PersonServiceImpl"
     implementation="com.journaldev.jaxws.service.PersonServiceImpl"
     url-pattern="/personWS"/>
</endpoints>
```
  1. 什么是 JAX-RS API?

Java API for RESTful Web Services (JAX-RS) is the Java API for creating REST web services. JAX-RS uses annotations to simplify the development and deployment of web services. JAX-RS is part of JDK, so you don’t need to include anything to use it’s annotations.
  1. 列出 JAX-RS API 的一些实现?

There are two major implementations of JAX-RS API.
1.  Jersey: Jersey is the reference implementation provided by Sun. For using Jersey as our JAX-RS implementation, all we need to configure its servlet in web.xml and add required dependencies. Note that JAX-RS API is part of JDK not Jersey, so we have to add its dependency jars in our application.
2.  RESTEasy: RESTEasy is the JBoss project that provides JAX-RS implementation.
  1. wsimport 实用程序是什么?

We can use wsimport utility to generate the client stubs. This utility comes with standard installation of JDK. Below image shows an example execution of this utility for one of JAX-WS project. [![wsimport, parse wsdl, web services interview questions, restful interview questions, soap interview questions](https://journaldev.nyc3.digitaloceanspaces.com/2015/10/wsimport-utility-parse-wsdl-450x293.png)](https://journaldev.nyc3.digitaloceanspaces.com/2015/10/wsimport-utility-parse-wsdl.png)
  1. JAX-RS API 中使用的重要注释的名称?

Some of the important JAX-RS annotations are:
-   `@Path`: used to specify the relative path of class and methods. We can get the URI of a webservice by scanning the Path annotation value.
-   `@GET`, `@PUT`, `@POST`, `@DELETE` and `@HEAD`: used to specify the HTTP request type for a method.
-   `@Produces`, `@Consumes`: used to specify the request and response types.
-   `@PathParam`: used to bind the method parameter to path value by parsing it.
  1. 有什么用@XmlRootElement注解?

XmlRootElement annotation is used by JAXB to transform java object to XML and vice versa. So we have to annotate model classes with this annotation.
  1. 如何在HTTP响应中设置不同的状态码?

For setting HTTP status code other than 200, we have to use `javax.ws.rs.core.Response` class for response. Below are some of the sample return statements showing it's usage.

```
return Response.status(422).entity(exception).build();
return Response.ok(response).build(); //200
```

For a complete example, please read [RESTEasy Tutorial](/community/tutorials/resteasy-tutorial-eclipse-tomcat).

这就是全部网络服务面试问题,通过评论告诉我你对此的看法。如果您认为我遗漏了一些重要问题,请通过评论告诉我,我很乐意回答并添加到列表中。

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

Web 服务面试问题 - SOAP、RESTful 的相关文章

  • 使用itext java库复制时pdf文件大小大大增加

    我正在尝试使用 Java 中的 itextpdf 库将现有的 pdf 文件复制到一些新文件中 我使用的是 itextpdf 5 5 10 版本 我在两种方式上都面临着不同的问题 PDFStamper 和 PdfCopy 当我使用 PDFSt
  • 从 Android 函数更新 Textview

    有人可以告诉我如何从函数更新 Android Textview 控件吗 我在互联网上进行了深入搜索 看到很多人都问同样的问题 我测试了线程但无法工作 有人有一个简单的工作示例吗 例如 调用一个函数 在循环中运行多次 并且该函数在 TextV
  • java 拖放

    我尝试熟悉java中的拖放 但我发现的所有教程都是 让我生气 我想要的只是从 JList 包含在名为 UserPanel 的自制 JPanel 中 拖动 PublicUserLabel 并将其放入从 JTabbedPanel 继承的自制类中
  • Selector.close() 是否关闭所有客户端套接字?

    我是 nio 套接字的新手 我已经使用 nio 套接字编写了一个服务器 现在我正在尝试编写关闭钩子以确保通过清理资源正常退出 我的问题是Selector close 方法关闭所有客户端套接字 如果没有 请告诉我如何访问所有客户端套接字 而无
  • ZeroDateTimeBehavior=convertToNull 在使用 hibernate 的 jdbc url 中不起作用

    通过 extern 属性文件 url 指定如下 jdbc mariadb xxxxx 3306 xxxxx zeroDateTimeBehavior convertToNull 连接工作正常并且能够查询数据库 通过休眠 我创建了一个映射到带
  • java中高效的输入流到字符串方法

    因此 我在 Java 中的 诚然非常简单 应用程序上运行探查器 令我惊讶的是 仅次于需要在时间上发出 HTTP 请求的方法的是我的方法 inputStreamToString方法 目前它的定义如下 public static String
  • Spring Data Jpa OneToMany 同时保存子实体和父实体?

    这是我的父实体 注意 为了简洁起见 删除了 getter setter lombok 注释 Entity public class Board Id GeneratedValue strategy GenerationType IDENTI
  • 无法在 Intellij 中运行主类[重复]

    这个问题在这里已经有答案了 我有以下项目结构 ProjectRoot src Main examples libs My src文件夹被标记为sources在 Intellij 中 现在 当我想运行 Main 类时 出现以下错误 Excep
  • 传递自定义类型查询参数

    如何接受自定义类型查询参数 public String detail QueryParam request final MYRequest request 上面的行在启动服务器时出现错误 jersey server model ModelV
  • 使用 https 的 Web 服务身份验证给出错误

    我编写了一个简单的 Web 服务 并使用摘要和 HTTPS 身份验证来保护它 我已经使用 Java 中的 keytool 生成了我的证书 当我通过创建 war 文件在 Tomcat 中部署 Web 服务时 axis 的欢迎页面正确显示 但是
  • 用于制作代码编辑器的 JavaFX 相当于 JSyntaxPane 的什么?

    以前在 Swing 中 我使用过JSyntaxPane用于制作一个小型 Java 源代码编辑器 为了练习 我决定用 JavaFX 重做整个项目并添加对更多语言的支持 最好是尽可能多 不过好像没有什么类似的JSyntaxPane 一些研究让我
  • Google 表格使用 API 密钥而不是 client_secret.json

    In the QuickStart java示例Java 快速入门 https developers google com sheets api quickstart java他们使用OAuth client ID识别该应用程序 这会弹出一
  • java.exe 以非零退出值 1 结束

    只是为了开始 我并不是真正尝试从 Android 中的 xlsx 文件中读取单元格 我已经尝试了几乎所有我在 Google 上搜索到的内容 但是每次 在两台不同的 PC 上 都是 Java 1 7 0 79 当我尝试构建 运行 这个应用程序
  • 从字符串中删除重音符号

    Android 中有没有什么方法 据我所知 没有 java text Normalizer 可以从字符串中删除任何重音 例如 变成 eau 如果可能的话 我想避免解析字符串来检查每个字符 java text NormalizerAndroi
  • BigDecimal汇总统计

    我有一个 BigDecimal 列表 List
  • React Native v0.71.8 React-native-vector-icons 你看不到的图标

    我在用react native版本v0 71 8 我安装了react native vector icons库 但图标未显示 似乎链接在最新版本的 React Native 中不再起作用 所以我按照说明进行操作 但它不再编译 出现以下错误
  • 在 Spring MVC 中将请求写入文件

    我希望能够将整个请求写入 Spring MVC 控制器中的文件 我已尝试以下操作 但即使我使用大量参数发出 POST 请求 文件也始终为空 RequestMapping method RequestMethod POST value pay
  • 难以理解 通配符

    我有一个非常基本的问题 下面的代码无法编译 假设 Apple Extends Fruit List
  • junit4 使用特定测试方法创建测试套件

    在 junit4 中 我想执行来自不同类的特定测试方法 即想要使用来自不同类的特定测试方法创建一个测试套件 假设我有两门课 public class Test Login Test public void test Login 001 Sy
  • 假布尔值=真?

    我在一本书中找到了这段代码 并在 Netbeans 中执行了它 boolean b false if b true System out println true else System out println false 我只是不明白为什

随机推荐

  • 如何在 Python 中注释

    编写 Python 代码时 让代码简洁且易于理解始终是一个好习惯 组织代码 为变量和函数指定描述性名称是实现此目的的几种方法 提高代码可读性的另一种方法是使用注释 注释是用于解释代码的人类可读的解释或注释 例如 如果您编写了一个复杂的正则表
  • 如何在 Debian Linux 9 上安装 VirtualBox

    虚拟盒子是一款开源跨平台虚拟化软件 允许您同时运行多个来宾操作系统 虚拟机 本教程介绍如何在 Debian 9 上安装最新的 VirtualBox 6 0 先决条件 您需要以以下身份登录具有 sudo 访问权限的用户能够在 Debian 系
  • 如何在 Debian 10 上安装 TensorFlow

    TensorFlow是谷歌打造的一个开源机器学习平台 它可以在不同设备上的CPU或GPU上运行 TensorFlow 可以在 Python 虚拟环境中安装在系统范围内 作为Docker容器 或使用 Anaconda 在本教程中 我们将解释如
  • 如何在 Ubuntu 16.04 上将 Apache Web 根移动到新位置

    介绍 在 Ubuntu 上 默认情况下 Apache2 Web 服务器将其文档存储在 var www html 它通常与操作系统的其余部分一起位于根文件系统上 但有时 将文档根移动到另一个位置会很有帮助 例如单独安装的文件系统 例如 如果您
  • 如何在 Ubuntu 16.04 上使用 Apache 和 mod_wsgi 为 Django 应用程序提供服务

    介绍 Django 是一个功能强大的 Web 框架 可以帮助您快速启动 Python 应用程序或网站 Django 包含一个简化的开发服务器 用于在本地测试代码 但对于任何与生产稍微相关的事情 都需要更安全 更强大的 Web 服务器 在本指
  • Java线程等待、通知和notifyAll示例

    java中的Object类包含三个final方法 允许线程就资源的锁定状态进行通信 这些方法是wait notify and 通知全部 那么今天我们就来研究一下java程序中的wait notify和notifyAll Java中的等待 通
  • Systemd 要点:使用服务、单位和期刊

    介绍 近年来 Linux 发行版越来越多地从其他 init 系统过渡到systemd The systemd工具套件提供了快速灵活的初始化模型 用于从启动开始管理整个机器 在本指南中 我们将向您快速介绍您在管理应用程序时需要了解的最重要的命
  • Primefaces FileUpload 组件示例教程

    今天我们将研究 Primefaces FileUpload 组件 HTML 为您提供file输入标签来选择文件 但是我们需要更多信息才能将文件上传到服务器 Primefaces 为您提供现成的解决方案 消除了这种负担文件上传组件帮助您创建漂
  • 如何在 CentOS 7 上为 Nginx 创建自签名 SSL 证书

    介绍 TLS 或传输层安全 及其前身SSL代表安全套接字层 是用于将正常流量包装在受保护的加密包装器中的 Web 协议 使用此技术 服务器可以在服务器和客户端之间安全地发送流量 而不会出现消息被外部各方拦截的可能性 证书系统还帮助用户验证他
  • 如何在 Angular Material 中使用自定义 SVG 图标

    介绍 The 角材料库提供了一套采用 Material Design 风格的 Angular 组件 其中一个这样的组件是
  • 如何在 Ubuntu 12.04 上安装 MongoDB

    Status 已弃用 本文介绍不再受支持的 Ubuntu 版本 如果您当前运行的服务器运行 Ubuntu 12 04 我们强烈建议您升级或迁移到受支持的 Ubuntu 版本 升级到Ubuntu 14 04 从 Ubuntu 14 04 升级
  • React Router v6 抢先体验

    在撰写本文时 React Router v6 仍处于 alpha 阶段 但现在是时候开始使用它并探索未来的发展了 本指南将带您了解新功能 变化 如您所知 主要维护者分叉了反应路由器项目创建一个轻量级替代品 称为到达路由器2018年初 在此期
  • 在 Linux 中减小 PDF 文件大小

    在我们的 Linux 系统中 如果我们有一个很大的 PDF 文件 我们可能想减小它的大小 在本教程中 我们将了解在 Linux 中减小 PDF 大小或压缩 PDF 文件的不同方法 让我们找出一些命令行和 GUI 方法来处理这个问题 在 Li
  • 如何在 FreeBSD 10.1 上安装 Apache、MySQL 和 PHP (FAMP) 堆栈

    介绍 FAMP 堆栈类似于 Linux 上的 LAMP 堆栈 是一组开源软件 通常安装在一起以使 FreeBSD 服务器能够托管动态网站和 Web 应用程序 FAMP 是首字母缩略词 代表FfreeBSD 操作系统 A阿帕奇 网络服务器 M
  • 如何使用 JSON.parse() 和 JSON.stringify()

    介绍 The JSON object在所有现代浏览器中都可用 有两种有用的方法来处理 JSON 格式的内容 parse and stringify JSON parse JSON parse 获取 JSON 字符串并将其转换为 JavaSc
  • C++ 中的字符串连接:连接字符串的 4 种方法

    在本文中 我们将揭示在中执行字符串连接的各种方法C 语言 该方法在编程时可用于多种目的 但总的来说 这个概念与组合来自不同位置的两个字符串并将它们放在一起是相同的 C 中的字符串连接技术 在 C 中连接字符串时可以考虑以下技术 C 连接 运
  • 如何在 CentOS 7 上安装和使用 PostgreSQL

    介绍 关系数据库管理系统是许多网站和应用程序的关键组件 它们提供了一种结构化的方式来存储 组织和访问信息 PostgreSQLPostgres 或 Postgres 是一个关系数据库管理系统 提供 SQL 查询语言的实现 它是许多小型和大型
  • 如何在 VPS 上使用 Nginx 设置 FastCGI 缓存

    Prelude Nginx 包含一个 FastCGI 模块 该模块具有用于缓存 PHP 后端提供的动态内容的指令 设置此功能无需额外的页面缓存解决方案 例如反向代理 想想Varnish 或特定于应用程序的插件 还可以根据请求方法 URL c
  • DNS 术语、组件和概念简介

    介绍 DNS 即域名系统 通常是学习如何配置网站和服务器的一个非常困难的部分 了解 DNS 的工作原理将帮助您诊断配置网站访问的问题 并让您更深入地了解幕后发生的事情 在本指南中 我们将讨论一些基本的 DNS 概念 这些概念将帮助您开始使用
  • Web 服务面试问题 - SOAP、RESTful

    欢迎来到 Web 服务面试问题及其详细答案 最近我写了很多关于 Web 服务的文章 我们如何用 Java 创建 SOAP 和 RESTful Web 服务 Web 服务面试问题 Here I am providing you a list