小编PST*_*PST的帖子

Android SDK Manager未显示ARM EABI v7a系统映像选项

我正在尝试设置环境以在Android平台上构建应用程序.我已经按照http://developer.android.com/sdk/installing.html中的步骤操作,并安装了SDK和Eclispe ADT插件.运行Hello World应用程序时,收到错误消息:

SDK Manager]无法找到ABI armeabi的'userdata.img'文件以复制到AVD文件夹中.

为了解决这个问题,我尝试使用sysimg_armv7a-14_r01.zip文件安装ARM EABI v7a系统映像.

令人惊讶的是,我的Android SDK manage没有显示ARM EABI v7a System Image的选项以重新安装此软件包?我错过了任何一步吗? 在此输入图像描述

android

18
推荐指数
1
解决办法
5万
查看次数

Spring RestTemplate Client - 连接拒绝异常

我是webservices的新手,并尝试使用RestTemplate编写RESTFul webservice的客户端.我使用org.springframework.http.converter.xml.MarshallingHttpMessageConverter作为消息转换器,org.springframework.oxm.xstream.XStreamMarshaller作为marshaller.

有没有办法进一步调试这个或找出这个问题的根本原因?

我的消费者类看起来像这样 -

@SuppressWarnings("unchecked")
public List<Deal> getClientInformation() throws RestClientException {
    return restTemplate.getForObject(webServiceURL, List.class);
Run Code Online (Sandbox Code Playgroud)

}

例外:

Exception in thread "main" org.springframework.web.client.ResourceAccessException: I/O error: Connection refused: connect; nested exception is java.net.ConnectException: Connection refused: connect
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:359)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:307)
at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:177)
at main.java.com.sample.consumer.DealConsumer.getClientInformation(Consumer.java:35)
at main.java.com.client.WebserviceConsumerTestClient.main(WebserviceConsumerTestClient.java:16)
Run Code Online (Sandbox Code Playgroud)

引起:java.net.ConnectException:连接被拒绝:连接org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:359)

rest spring client web-services

11
推荐指数
1
解决办法
7万
查看次数

@NotNull注释不检查Jersey REST资源中的null queryparameter

我正在尝试使用javax.validation.validation-api来验证@QueryParam参数.我按照以下步骤操作:

  1. 添加依赖:

    <dependency>
        <groupId>javax.validation</groupId>
        <artifactId>validation-api</artifactId>
        <version>1.1.0.Final</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.glassfish.jersey.ext</groupId>
        <artifactId>jersey-bean-validation</artifactId>
        <version>2.12</version>
        <exclusions>
            <exclusion>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-validator</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    
    Run Code Online (Sandbox Code Playgroud)
  2. 泽西资源:

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    @Path("/{param1}")
    @ValidateOnExecution
    public SomeObject get(@PathParam("param1") String param1,
        @NotNull @QueryParam("q1") String q1,
        @NotNull @QueryParam("q2") String q2) {
    
        try {
            //Assuming q1 and q2 are NOT Null here
            ...
        } catch(Exception exception) { 
            throw new WebApplicationException(exception, 
                    Response.Status.INTERNAL_SERVER_ERROR);
        }
        return someObject;
    }     
    
    Run Code Online (Sandbox Code Playgroud)
  3. 我尝试给出各种URL的组合,如在q1和q2中,两个参数都不存在,q1缺席或q2缺席.每次@NotNull都没有被发现.意味着尝试块代码正在执行,而不管q1和q2是什么null.

还有什么需要做的?

我引用了这个链接 - https://jersey.java.net/documentation/latest/bean-validation.html#d0e11956.

如何在我的环境中检查Auto-Discoverable功能是否已启用?

rest jersey bean-validation

10
推荐指数
0
解决办法
5023
查看次数

在一个 div 中水平或垂直排列元素

我正在尝试编写通用 css 选择器,它将垂直或水平排列任何包裹在 div 内的元素。我无法控制将放置在外部 div 内的元素。

例如:在下面的代码段中,div (id=one)、div(id=two) 和 button (id =three) 应该显示为水平排列的元素列表。

<div class="arrange-horizontally">
  <div id="one"></div>
  <div id="two"></div>
  <button id="three"></button>
</div>
Run Code Online (Sandbox Code Playgroud)

同样,我需要编写另一个 css 选择器来以垂直方式排列元素。

<div class="arrange-vertically">
  <div id="one"></div>
  <div id="two"></div>
  <button id="three"></button>
</div>
Run Code Online (Sandbox Code Playgroud)

我尝试使用 display:table-row (水平显示这些元素)。display:table-cell 不会垂直排列元素。实际上; 我正在寻找更好的方法,然后是解决方案。

这是我用来获得所需效果的 css。还有一个变化,我确保垂直或水平样式的 div 都包含在一个带有 .table 的 div 中。 下面只是示例之一,可能还有更多这样的组合。

<div class="table>
    <div class="arrange-vertically">
       <div>
             <button>1stverticallyPlacedElement</button>
   </div>
       <div class="arrange-horizontally">
             <div>some comp1</div>
             <div>some comp1</div>
             <div>some comp2</div>
       </div>

      <button id="three">This is 3rd element in vertical block</button>
    </div>
</div>


    .table {
        display: table;
     } …
Run Code Online (Sandbox Code Playgroud)

css

5
推荐指数
2
解决办法
4万
查看次数

Java正则表达式的模式应该编译为静态数据成员还是实例变量?

我有一个实用程序类,其中包含所有静态方法,其中一个方法需要正则表达式匹配。

将模式声明为类的静态数据成员是好习惯还是将其声明为使用该模式的方法的实例变量是否可以?同一类的多个方法不会使用此模式。虽然这个实用方法可以被多个线程调用。

public final class Utility {
   public static someMethod(Sting in) {
      Pattern p = Pattern.compile("some pattern expression");
      Matcher m = p.matcher(in);
      if (m.matches()) {
         //do something
      }
   }
}
Run Code Online (Sandbox Code Playgroud)

或者下面的方法更好?

public final class Utility {
   private static final Pattern p = Pattern.compile("some pattern expression");
   public static someMethod(Sting in) {
      Matcher m = p.matcher(in);
      if (m.matches()) {
         //do something
      }
   }
}
Run Code Online (Sandbox Code Playgroud)

java regex

5
推荐指数
2
解决办法
5082
查看次数

Java私有方法签名清晰度和更好的实践

我收到了以下代码段的代码审核评论 -

public void doWork(String a, Integer b) {
    ..
    ..
    SomeService service = getService();
    for (Integer i : numbers) {
      doMoreWork(a, b, service);
    }
}
private void doMoreWork(String a, Integer b, SomeService service) {
    ...
    ...
    ...
    service.doingMoreWork(a, b);
}
Run Code Online (Sandbox Code Playgroud)

审查建议 -

  1. SomeService service = getService();应该在内部进行调用doMoreWork以便签名清晰.所以签名变得doMoreWork(a, b)更清楚易懂.

我的问题 -

由于doMoreWork()发生在循环中,我将服务对象传递给它.doMoreWork()只是代码中的私有逻辑单元,将"service"作为方法参数进行处理应该没问题.这种方法永远不会公开.这种情况下的指导原则是什么?这里的清晰度或可读性如何受到影响?

(注意 :

  1. getService()调用没有太多性能开销,因此性能不是我的标准.
  2. 服务注入不是一种选择.它需要以样本中显示的方式获取.
  3. doMoreWork()不只是调用service.doingMoreWork().它有一些预先步骤可以遵循.

)

java code-readability

5
推荐指数
1
解决办法
418
查看次数