小编Evg*_*eny的帖子

如何从bootRun传递JVM选项

我正在开发与远程主机通信的简单Spring Web应用程序,我想在公司代理后面进行本地测试.我使用"Spring Boot"gradle插件,问题是如何为JVM指定代理设置?

我尝试了几种方法:

  1. gradle -Dhttp.proxyHost=X.X.X.X -Dhttp.proxyPort=8080 bootRun
  2. export JAVA_OPTS="-Dhttp.proxyHost=X.X.X.X -Dhttp.proxyPort=8080"
  3. export GRADLE_OPTS="-Dhttp.proxyHost=X.X.X.X -Dhttp.proxyPort=8080"

但似乎没有一个工作 - "NoRouteToHostException"抛出"网络"代码.另外,我添加了一些额外的代码来调试JVM启动参数:

    RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean();
    List<String> arguments = runtimeMxBean.getInputArguments();
    for (String arg: arguments) System.out.println(arg);
Run Code Online (Sandbox Code Playgroud)

并且只打印了一个参数:" - Dfile.encoding = UTF-8".

如果我在代码中设置系统属性:

    System.setProperty("http.proxyHost", "X.X.X.X");
    System.setProperty("http.proxyPort", "8080");
Run Code Online (Sandbox Code Playgroud)

一切正常!

java gradle spring-boot

88
推荐指数
4
解决办法
6万
查看次数

滚动期间列表项变为黑色,setCacheColorHint()不起作用

我的ListViewAndroid应用程序中有两个颜色(奇数元素一种颜色,偶数颜色一种颜色).它在Froyo上运行得很好.但是在Jelly Bean模拟器上,滚动期间会出现一些文物.一些元素的背景变黑.是的,我知道透明缓存颜色提示的解决方案!但它只有在我以这种方式设置背景时才有效:

bindView()适配器的方法:

// ...
view.setBackgroundResource(
        cursor.getPosition() % 2 == 0 ? R.color.list_item_bg1: R.color.list_item_bg2);
Run Code Online (Sandbox Code Playgroud)

但是这个方法不适合我,因为我想突出显示元素,然后用户点击它.所以我StateListDrawable用于此目的:

mOddColorDrawable = new ColorDrawable(
        context.getResources().getColor(R.color.list_item_bg2));
mEvenColorDrawable = new ColorDrawable(
        context.getResources().getColor(R.color.list_item_bg1));
mSelector = new ColorDrawable(
    context.getResources().getColor(R.color.list_item_selector));

public void bindView(View view, Context context, Cursor cursor) {
    // ...
    setBackground(cursor.getPosition % 2 != 0, view);
}

public void setBackground(boolean isOdd, View listItem) {
    StateListDrawable dr = new StateListDrawable();
    Drawable drColor = isOdd ? mOddColorDrawable : mEvenColorDrawable;
    dr.addState(new int[] { android.R.attr.state_pressed …
Run Code Online (Sandbox Code Playgroud)

android android-listview

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

chaiHttp 忽略端口

我正在尝试使用 chaiHttp 为由 nodejs 驱动的 API 编写测试。这是我的测试代码:

const mongoose = require("mongoose");
const Products = require('../models/product');

const chai = require('chai');
const chaiHttp = require('chai-http');
const server = require('../server');
const should = chai.should();
const assert = chai.assert;

chai.use(chaiHttp);

describe('Products', () => {
  beforeEach(done => {Products.remove({}, done);});

  describe('/GET products', () => {
    it('it should GET all the products', (done) => {
      //chai.request(server)
      chai.request("http://127.0.0.1:3000")
          .get('api/products')
          .end((err, res) => {
            if (err) {
              assert(false, 'err response: ' + err);
              return;
            }
            res.should.have.status(200);
            res.body.should.be.a('array');
            res.body.length.should.be.eql(0);
            done(); …
Run Code Online (Sandbox Code Playgroud)

javascript node.js chai

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