小编Mul*_*ard的帖子

无法自动装配`WebTestClient` - 无需自动配置

我们使用spring framework 5和spring boot 2.0.0.M6,我们也WebClient用于反应式编程.我们为我们的反应式休息端点创建了测试方法,因此我查找了一些关于如何操作的示例.我发现这个或者这个以及许多其他的都是一样的.他们只是自动装配一个WebTestClient.所以我尝试了同样的事情:

@Log
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
public class MyControllerTest {

    @Autowired
    private WebTestClient webClient;

    @Test
    public void getItems() throws Exception {
        log.info("Test: '/items/get'");

        Parameters params = new Parameters("#s23lkjslökjh12", "2015-09-20/2015-09-27");

        this.webClient.post().uri("/items/get")
                .accept(MediaType.APPLICATION_STREAM_JSON)
                .contentType(MediaType.APPLICATION_STREAM_JSON)
                .body(BodyInserters.fromPublisher(Mono.just(params), Parameters.class))
                .exchange()
                .expectStatus().isOk()
                .expectHeader().contentType(MediaType.APPLICATION_STREAM_JSON)
                .expectBody(Basket.class);
    }
}
Run Code Online (Sandbox Code Playgroud)

我无法运行,因为我收到错误:

Could not autowire. No beans of 'WebTestClient' type found.
Run Code Online (Sandbox Code Playgroud)

因此,似乎不存在自动配置.我使用的是错误版本还是这里有什么问题?

spring spring-boot spring-webflux

17
推荐指数
2
解决办法
7529
查看次数

Docker Compose:depends_on 条件 -> 无效类型,应该是一个数组

我有以下撰写文件:

version: "3"

services:

  zookeeper:
    image: docker-dev.art.intern/wurstmeister/zookeeper:latest
    ports:
      - 2181:2181

  kafka:
    image: docker-dev.art.intern/wurstmeister/kafka:latest
    ports:
      - 9092:9092
    environment:
      - KAFKA_LISTENERS=PLAINTEXT://:9092
      - KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092
      - KAFKA_ADVERTISED_HOST_NAME=kafka
      - KAFKA_ADVERTISED_PORT=9092
      - KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181
    depends_on:
      - zookeeper

  app:
    build:
      context: ./
      dockerfile: app/Dockerfile
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:4020/actuator/health"]
      interval: 30s
      timeout: 10s
      retries: 5
    depends_on:
      - kafka
      - zookeeper

  app-test:
    build:
      context: ./
      dockerfile: test/Dockerfile
    depends_on:
      app:
        condition: service_healthy
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,我正在为应用程序实施运行状况检查,并且我使用service_healthy条件。但这会导致错误:

The Compose file '.\docker-compose.yml' is invalid because:
services.app-test.depends_on contains an invalid type, it should …
Run Code Online (Sandbox Code Playgroud)

yaml docker docker-compose

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

Chart.js每个数据集的不同标签的折线图

使用Chart.js可以创建折线图,为此您必须使用标签和数据集.例如:

var data = {
    labels: ["January", "February", "March", "April", "May", "June", "July"],
    datasets: [
        {
            label: "My First dataset",
            fill: false,
            lineTension: 0.1,
            backgroundColor: "rgba(75,192,192,0.4)",
            borderColor: "rgba(75,192,192,1)",
            borderCapStyle: 'butt',
            borderDash: [],
            borderDashOffset: 0.0,
            borderJoinStyle: 'miter',
            pointBorderColor: "rgba(75,192,192,1)",
            pointBackgroundColor: "#fff",
            pointBorderWidth: 1,
            pointHoverRadius: 5,
            pointHoverBackgroundColor: "rgba(75,192,192,1)",
            pointHoverBorderColor: "rgba(220,220,220,1)",
            pointHoverBorderWidth: 2,
            pointRadius: 1,
            pointHitRadius: 10,
            data: [65, 59, 80, 81, 56, 55, 40],
        }
    ]
};
Run Code Online (Sandbox Code Playgroud)

这里的问题是你有一定数量的标签(在这种情况下为7),你还需要为每个数据集提供7个数据条目.现在如果您有不明数量的标签和数据条目怎么办?

如果一个数据条目包含数字和时间,该怎么办:

Entry {
    number: 127
    time: 10:00
}
Run Code Online (Sandbox Code Playgroud)

如果要在X轴上显示所有时间,在Y轴上显示所有数字,请按X轴上的时间排序,该怎么办?Chart.js有可能吗?

javascript charts chart.js

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

为什么cgImage?.cropping旋转图像?

我写了一个UICropperViewController,它在横向模式下完美地适用于图像.纵向模式下的图像存在很大问题.下图显示了带有黄色裁剪框的简单图片:

在此输入图像描述

裁剪结果是:

在此输入图像描述

现在谈到肖像图像我们得到了这种情况:

在此输入图像描述

结果如下:

在此输入图像描述

那么这里发生了什么?原始图像自动向左旋转.

我研究了很多,基本上找到了两个建议:

建议1

在裁剪之前保存图像方向并恢复它.

func didTapCropButton(sender: AnyObject) {
    let originalOrientation = self.imageView.image?.imageOrientation;

    // raw value of originalOrientation is `3` so its rotated to the right

    let croppedCGImage = self.imageView.image?.cgImage?.cropping(to: self.cropArea);

    // create a cropped cgImage

    let croppedImage = UIImage(cgImage: croppedCGImage!, scale: (self.imageView.image?.scale)!, orientation: (originalOrientation)!);

    // create the UIImage with the result from cgImage cropping and original orientation

    if (self.callback != nil) {
        self.callback.croppingDone(image: croppedImage);
    }

    self.dismiss(animated: true, completion: nil);
}
Run Code Online (Sandbox Code Playgroud)

但结果现在是:

在此输入图像描述

显然这个建议不起作用,因为它只是简单地旋转已经裁剪的图像.

建议2

定位修复.我找到了以下代码,并承诺会修复错误: …

uiimageview uiimage cgimage ios swift

12
推荐指数
1
解决办法
4044
查看次数

摄像机结果始终返回RESULT_CANCELED

我想用相机拍照.我只是暂时需要它们,所以我做了以下事情:

private void takePicture() {
    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

    if (intent.resolveActivity(this.getActivity().getPackageManager()) != null) {
        try {
            this.imageFile = File.createTempFile("CROP_SHOT", ".jpg", this.getActivity().getCacheDir());

            intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(this.imageFile));
            intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);

            this.startActivityForResult(intent, Globals.REQUEST_TAKE_PHOTO);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

不幸的RESULT_CANCELED是我的结果代码onActivityResult

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    Log.v("PictureEdit", "onActivityResult");

    super.onActivityResult(requestCode, resultCode, data);

    if(resultCode == Activity.RESULT_OK) {
        if(requestCode == Globals.REQUEST_TAKE_PHOTO) {
            Log.v("PictureEdit", "onActivityResult take photo");

            this.startCropImage(Uri.fromFile(this.imageFile));
        } else if (requestCode == Globals.REQUEST_PICK_PHOTO) {
            Log.v("PictureEdit", "onActivityResult pick photo"); …
Run Code Online (Sandbox Code Playgroud)

android android-camera

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

GestureDetector的onScroll()和onFling()之间的区别

是什么区别onScroll(),并onFling()GestureDetector界面?当我打印出事件时,他们会显示完全相同的事情.至少是最后一个onScroll()onFling().

我注意到的唯一真正的区别是,onScroll()更频繁地调用,总是只有一次.

android android-gesture

10
推荐指数
1
解决办法
6891
查看次数

如何为展开/折叠视图的图标设置动画?

我有这个图标:

在此输入图像描述

当我在列表视图中按下我的项目时,我希望它旋转180°.当我再次点击时,我希望它再旋转180°,这样就可以达到它的原始位置.

首先我试过:

view.animate().rotation(180).setDuration(500).start();
Run Code Online (Sandbox Code Playgroud)

但它只发射一次.之后我尝试了:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:fillAfter="true"
    android:fillEnabled="true">

    <rotate
        android:duration="500"
        android:fromDegrees="0"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toDegrees="180" />
</set>
Run Code Online (Sandbox Code Playgroud)

但是,即使箭头已经显示在顶部,动画始终以箭头显示到按钮并旋转到顶部开始.

那我怎么能让它工作呢?

animation android

10
推荐指数
2
解决办法
7499
查看次数

如何制作Scrollview所有内容的屏幕截图?

我想创建一个截图,UIScrollView其中应包含滚动视图的整个内容,甚至包含当前用户不可见的内容.为此,我尝试了以下两种方法:

func snapShot(view:UIView) -> UIImage {
    UIGraphicsBeginImageContextWithOptions(view.bounds.size, true, 0);

    view.drawViewHierarchyInRect(view.bounds, afterScreenUpdates: true);

    let image = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    return image;
}

func snapShotScrollView(scrollView:UIScrollView) -> UIImage {
    let bounds = scrollView.bounds;

    scrollView.bounds.size = scrollView.contentSize;

    let image = snapShot(scrollView);

    scrollView.bounds = bounds;

    return image;
}
Run Code Online (Sandbox Code Playgroud)

但是生成的图像仍然只显示滚动视图中当前对用户可见的那些视图元素.但我希望看到所有观点.

我怎样才能做到这一点?

编辑

我也尝试过:

func snapshot() -> UIImage? {
    var image: UIImage?

    UIGraphicsBeginImageContext(scrollView.contentSize)

    let savedContentOffset = scrollView.contentOffset
    let savedFrame = scrollView.frame;

    scrollView.contentOffset = CGPoint.zero;
    scrollView.frame = CGRect(x: 0, y: 0, width: scrollView.contentSize.width, height: scrollView.contentSize.height);

    scrollView.layer.render(in: UIGraphicsGetCurrentContext()!) …
Run Code Online (Sandbox Code Playgroud)

screenshot uiscrollview ios swift swift3

10
推荐指数
1
解决办法
2952
查看次数

ListView展开项目的动画仅在第二次单击后才有效

我有一个带有以下视图的CardView:

- RelativeLayout (view_1)
    - TextView
    - TextView

- RelativeLayout (view_2)
    - ImageView
    - ImageView
Run Code Online (Sandbox Code Playgroud)

当我打开我的ListViewview_2设置为Visible.GONE所以你无法看到它.现在,我使用的ExpandAnimation这个博客.在这里你有代码:

/**
 *
 */
public class ExpandAnimation extends Animation {
    /**
     *
     */
    private AnimationCallback callback = null;
    /**
     *
     */
    private View viewToAnimate = null;
    /**
     *
     */
    private RelativeLayout.LayoutParams viewToAnimateLayoutParams = null;
    /**
     *
     */
    private int marginStart = 0;
    /**
     *
     */
    private int marginEnd = 0;
    /**
     *
     */
    private boolean isVisibleAfter = …
Run Code Online (Sandbox Code Playgroud)

android visibility onclick android-animation android-view

8
推荐指数
1
解决办法
695
查看次数

如何迭代recyclerview中的视图项?

我有一个RecyclerView以下适配器:

public class DataTransferMeasureListAdapter extends DataTransferBaseListAdapter<DataTransferMeasureListAdapter.ViewHolder> {
    private Context context = null;
    private List<DataTransferListEntry> entries = null;

    public DataTransferMeasureListAdapter(Context context, List<DataTransferListEntry> entries) {
        super(context);

        this.context = context;
        this.entries = entries;
    }

    @Override
    public DataTransferMeasureListAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View itemView = LayoutInflater.from(context).inflate(R.layout.fragment_datatransfer_measure_list_row, parent, false);

        return new DataTransferMeasureListAdapter.ViewHolder(this.context, itemView);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        final DataTransferMeasureListEntry entry = (DataTransferMeasureListEntry) entries.get(position);
        final ViewHolder viewHolder = (ViewHolder) holder;

        String time = Helper.getDateTimePattern(this.context, entry.getDate());
        String value = …
Run Code Online (Sandbox Code Playgroud)

android

8
推荐指数
1
解决办法
6680
查看次数