小编ris*_*ide的帖子

仅针对单个方法运行junit测试

你可以只为一个方法运行测试,而不是整个类吗?理想情况下来自命令行.

例如,对于一个班级:

public class TestClass extends Unittest {
  @Test
  public void test1_shouldbeRun() {

  }

  @Test
  public void test2_shouldNotBeRun() {

  } 
}
Run Code Online (Sandbox Code Playgroud)

我只想运行方法"test1_shouldBeRun".

java junit unit-testing playframework

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

使用带Swagger的多个JAX-RS应用程序类

我正在尝试在具有两个Application类的Java应用程序上实现Swagger,因为一个处理"公共"Web服务而另一个处理"admin"Web服务.我正在尝试生成两个单独的swagger.json文件,每个文件对应一个Application类.但是,两个URL中只生成其中一个.这是一些代码:

公共应用类:

@WebServlet
@ApplicationPath("/public") 
public class PublicApplication extends Application {

    public PublicApplication() {

        BeanConfig beanConfig = new BeanConfig();
        beanConfig.setVersion("1.0");
        beanConfig.setTitle("A Fine Title");
        beanConfig.setDescription("A Fine Description.");
        beanConfig.setSchemes(new String[]{"http"});
        beanConfig.setBasePath("/api"); 
        beanConfig.setResourcePackage("com.test.rest.resource.external");
        beanConfig.setPrettyPrint(true);
        beanConfig.setScan(true);
    }
}
Run Code Online (Sandbox Code Playgroud)

私人申请类:

@WebServlet
@ApplicationPath("/admin") 
public class AdminApplication extends Application {

    public AdminApplication() {

        BeanConfig beanConfig = new BeanConfig();
        beanConfig.setVersion("1.0");
        beanConfig.setTitle("Another Fine Title");
        beanConfig.setDescription("Another Fine Description.");
        beanConfig.setSchemes(new String[]{"http"});
        beanConfig.setBasePath("/apiTwo"); 
        beanConfig.setResourcePackage("com.test.rest.resource.internal");
        beanConfig.setPrettyPrint(true);
        beanConfig.setScan(true);
    }
}
Run Code Online (Sandbox Code Playgroud)

现在,如果我点击这些网址中的任何一个,我会得到相同的"公共"swagger json文件:

我究竟做错了什么? …

java web-services jax-rs swagger swagger-2.0

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

未处理的Promise拒绝:没有HTTPService的提供者

我正在将我的应用程序迁移到最新的RC并且遇到一些我无法解决的错误.在决定问这里之前,我做了一个彻底的搜索,但没有任何运气.

因此,按下按钮时,应加载以下内容:

这是组件:

import { Component,OnInit } from '@angular/core';

import { HTTPService } from '../shared/api.service';
import { Server } from './server.model';
import { SharedService } from '../shared/moveData.service';


@Component({
    templateUrl: './mainserverpage.template.html',
})
export class MainServerPage implements OnInit {

    constructor(private _httpService: HTTPService, 
                private _moveData: SharedService) { }

    errorMessage: string;
    public servers: Server[];
    isLoading = true;
    tillLoading;
    selectedServer: Server;
    currentServer;
    isServerOnline=false;

    ngOnInit() {
          this.getServers('qa');
    }

    reloadServers(env) {
        this.servers = null;

        this.getServers(env);
    }

    getServers(env?) {
        this._httpService.getServers(env)
            .subscribe(
            value => {
                this.servers = …
Run Code Online (Sandbox Code Playgroud)

typescript angular2-routing angular2-services angular

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

通过 Java SDK 调用 DocuSign API 进行 OAuth 2.0 身份验证时出现“no_valid_keys_or_signatures”错误

我正在将应用程序的身份验证方法从 DocuSign 旧版身份验证升级到 DocuSign API 到 JWT Grant OAuth 2.0 身份验证。

我在进行 Java SDK API 调用时收到以下错误:

原因:com.docusign.esign.client.ApiException:请求服务器时出错,收到不成功的 HTTP 代码 400,响应正文:'{"error":"invalid_grant","error_description":"no_valid_keys_or_signatures"}' at com .docusign.esign.client.ApiClient.requestJWTUserToken(ApiClient.java:866)

我在 DocuSign 演示环境中执行此操作,并使用 docusign-esign-java jar - 版本 3.12.0。这是重要的代码片段:

    private OAuthToken getOAuthToken(final String integratorKey, final String userId, final String rsaPrivateKey) {

    final ApiClient apiClient = new ApiClient();
    OAuthToken oAuthToken = new OAuthToken();

    final List<String> scopes = Arrays.asList(Scope_SIGNATURE, Scope_IMPERSONATION);

    try {
        // call failing here on apiClient.requestJWTUserToken(...)
        oAuthToken = apiClient.requestJWTUserToken(integratorKey, userId, scopes, rsaPrivateKey.getBytes(), 10000);
    }
    catch (IllegalArgumentException | IOException …
Run Code Online (Sandbox Code Playgroud)

java oauth-2.0 docusignapi

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

JAXB编组 - 扩展现有类

我需要使用JAXB通过XML创建一系列Java对象,这些对象都扩展了已创建的公共基类(不使用JAXB).例如,假设我有以下我正在尝试生成的JAXB类:

Penguin.xml  -> Penguin.java
Robin.xml -> Robin.java
Cardinal.xml -> Cardinal.java
Run Code Online (Sandbox Code Playgroud)

我已经有一个现有的基类Bird.java,我希望上面的三个类能够扩展.

做这个的最好方式是什么?

谢谢你的帮助!

jaxb marshalling base-class

4
推荐指数
1
解决办法
7360
查看次数

使用 Apache Wink 通过 Java REST 服务返回 Excel 文档

我需要从 Java REST 服务返回 Microsoft Excel 文件。我正在使用 WebSphere 8.5,它本质上使用 Apache Wink,因为它是 JAX-RS 实现;这是我无法改变的要求。我也在使用 Java 7 JDK。这是我收到的错误:

org.apache.wink.server.internal.handlers.FlushResultHandler handleResponse 系统找不到 com.somewhere.else.message.core.BaseResponseMessage 类型和应用程序的 javax.ws.rs.ext.MessageBodyWriter 或 DataSourceProvider 类/ vnd.ms-excel 媒体类型。确保在 JAX-RS 应用程序中存在指定类型和媒体类型的 javax.ws.rs.ext.MessageBodyWriter。

这是我的 Java Resource 类方法:

@GET
@Path("/report")
@Produces("application/vnd.ms-excel")
public Response getReport() { 

    int fileSize = 0;

    byte[] reportByteArray = null;

    ResponseBuilder responseBuilder = null;
    InputStream report = null;

    BaseResponseMessage<InputStream> baseResponseMessage = new  
    BaseResponseMessage<InputStream>();

    Path reportPath = null;

    String localPath = "C:/Users/me/Report.xls";

    responseBuilder = Response.ok(baseResponseMessage); 

    responseBuilder.header("Content-Description", "File Transfer");
    responseBuilder.header("Content-Disposition", "attachment; 
         filename=Report.xls");
    responseBuilder.header("Content-Transfer-Encoding", …
Run Code Online (Sandbox Code Playgroud)

java rest excel apache-wink websphere-8

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

index.html 中的条件视口元标记

我有一个带有两个子模块的 angular 模块,一个用于用户,另一个用于管理员。当然他们共享同一个index.html文件。

在我的用户模块中,我希望<meta name="viewport" content="width=device-width, initial-scale=1"><head></head>标签中有index.html

虽然我希望它在我的管理模块中被删除,并且只拥有手机的桌面视图。

我厌倦了在 admin first 组件构造函数中执行此操作:

import { Meta } from '@angular/platform-browser';
this.meta.removeTag('name="viewport"'); 
Run Code Online (Sandbox Code Playgroud)

标签正在被删除,但那是在应用程序开始呈现并存在此元标签之后,因为它在其中,index.html所以它不会给出所需的结果

有什么建议实际上有条件地添加这个元吗?困难的部分是它应该在 index.html 的头部。

viewport meta-tags typescript angular angular5

4
推荐指数
1
解决办法
2057
查看次数

更改html复选框的背景颜色

是否有可能,如果是这样,如何更改HTML复选框的背景颜色?我特别谈到小支票符号后面的白盒子.

我已经对此进行了大量搜索,但尚未找到确凿的答案.

html checkbox background-color

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

这里没有将"exportAs"设置为"ngForm"的指令

我使用下面的代码在angularjs 2.0中提交表单,但是得到错误,没有导出的指令设置为ngForm和ngModel,但我正在使用.以下是我的表格:

<form name="form" (ngSubmit)="f.form.valid && register()" #f="ngForm" novalidate>
  <div class="form-group" [ngClass]="{ 'has-error': f.submitted && !username.valid }">
    <label for="firstName">First Name</label>
    <input type="text" class="form-control" name="firstName" [(ngModel)]="model.firstName" #firstName="ngModel"
           required/>
    <div *ngIf="f.submitted && !firstName.valid" class="help-block">First Name is required</div>
  </div>
  <div class="form-group" [ngClass]="{ 'has-error': f.submitted && !username.valid }">
    <label for="lastName">Last Name</label>
    <input type="text" class="form-control" name="lastName" [(ngModel)]="model.lastName" #lastName="ngModel" required/>
    <div *ngIf="f.submitted && !lastName.valid" class="help-block">Last Name is required</div>
  </div>
  <div class="form-group" [ngClass]="{ 'has-error': f.submitted && !username.valid }">
    <label for="username">Username</label>
    <input type="text" class="form-control" name="username" [(ngModel)]="model.username" #username="ngModel" required/> …
Run Code Online (Sandbox Code Playgroud)

typescript angular

3
推荐指数
1
解决办法
4827
查看次数

角度6.1 StaticInjectorError

当我在angular ng serve中运行cmd时,应用程序停止加载,并且出现以下错误。

错误错误:未捕获(承诺):错误:StaticInjectorError(AppModule)[AuthService-> Http]:StaticInjectorError(平台:core)[AuthService-> Http]:NullInjectorError:没有Http的提供者!错误:StaticInjectorError(AppModule)[AuthService-> Http]:StaticInjectorError(平台:core)[AuthService-> Http]:NullInjectorError:没有Http的提供程序!在NullInjector.push ../ node_modules/@angular/core/fesm5/core.js.NullInjector.get(core.js:979)在resolveToken(core.js:1232)

angular angular6

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