小编a_s*_*ber的帖子

Emacs。头盔包。如何查找文件夹(不是 git 文件夹)和所有子文件夹中的文件?

Windows 10(64 位)、Emacs 25.1、Helm 包。

要在任何文件夹(不是 git,不是项目文件)中查找文件(例如myfile.txt ),我使用命令helm-find-file。是工作。好的。

但现在我需要在当前文件夹和所有子文件夹中找到myfile.txt 。我如何通过helm包做到这一点?

emacs file emacs-helm

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

未达到覆盖范围检查

我想生成junit的测试覆盖率报告。所以我使用 jacoco maven 插件:

这是我的 pom.xml

 <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <compilerVersion>${java.version}</compilerVersion>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.8.8</version>
                <executions>
                    <execution>
                        <id>prepare-agent</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>report</id>
                        <phase>test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>jacoco-check</id>
                        <goals>
                            <goal>check</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <rule>
                                    <element>PACKAGE</element>
                                    <limits>
                                        <limit>
                                            <counter>LINE</counter>
                                            <value>COVEREDRATIO</value>
                                            <minimum>0.50</minimum>
                                        </limit>
                                    </limits>
                                </rule>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
Run Code Online (Sandbox Code Playgroud)

但是当我运行这个时:

mvn clean verify
Run Code Online (Sandbox Code Playgroud)

我收到错误:

Results :

Tests run: 3, Failures: 0, Errors: 0, Skipped: 0

[INFO] 
[INFO] --- jacoco-maven-plugin:0.8.8:report …
Run Code Online (Sandbox Code Playgroud)

maven jacoco

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

在开始Espresso测试之前如何准备数据库数据?

数据库:SQLite

表:联系方式

浓咖啡测试:

@Test
public void testBlock() {
   onData(anything()).inAdapterView(withId(R.id.container_ListView)).atPosition(0).onChildView(withText(R.string.block_user))
            .perform(click());
}
Run Code Online (Sandbox Code Playgroud)

并且测试成功通过。但是,只有在开始联系之前状态已解除阻止(数据库表中的列状态)时,它才会成功。因此,我需要(开始测试之前)将此联系人更新为unblock状态。我怎样才能做到这一点?还是有人对此有更好的解决方案?

android android-testing android-espresso

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

Emacs。如何删除包含某些文本的重复行

Windows 10(64 位)、Emacs 25.1

假设我有文本:

111111111 啊啊啊啊啊啊

222222 3333333333 44444444

111111111 啊啊啊啊啊啊

111111111 啊啊啊啊啊啊

44444444 666666666 777777777777

111111111 啊啊啊啊啊啊

所以我想删除包含aaaaaaaa的重复行。

结果一定是这样的:

111111111 啊啊啊啊啊啊

222222 3333333333 44444444

44444444 666666666 777777777777

我想使用 Emacs 的内置功能(无需编写自定义 elisp 脚本)。

emacs

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

安卓。浓缩咖啡:无法检查背景

Windows 10(64 位)、Android Studio 3.1.2、Gradle 4.4、Java 1.8。

这是我的布局 xml

<TextView
    android:id="@+id/loginTextView"
    android:layout_width="255dp"
    android:layout_height="60dp"
    android:layout_marginBottom="15dp"
    android:background="@drawable/sign_in_login_bg"
    android:gravity="center"                              
    app:layout_constraintBottom_toTopOf="@+id/registerTextView"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent" />
Run Code Online (Sandbox Code Playgroud)

这里@drawable/sign_in_login_bg

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid android:color="@color/color_primary" />
    <corners android:radius="@dimen/text_view_rounded_corner_radius" />
</shape>
Run Code Online (Sandbox Code Playgroud)

我想编写浓缩咖啡测试来检查loginTextView是否具有背景@drawable/sign_in_login_bg

所以我写了自定义匹配器:

import org.hamcrest.Matcher;
public static Matcher<View> withBackground(final int expectedResourceId) {
        
      return new BoundedMatcher<View, View>(View.class) {
        
          @Override
          public boolean matchesSafely(View view) {
              return sameBitmap(view.getContext(), view.getBackground(), expectedResourceId);
         }
        
         @Override
         public void describeTo(Description description) {
             description.appendText("has background resource " + expectedResourceId);
        }
    };
} …
Run Code Online (Sandbox Code Playgroud)

android-espresso

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

android 两个 buildTypes - 错误:重复的类

安卓工作室3.4

我有 2 种构建类型:

debug
release
Run Code Online (Sandbox Code Playgroud)

所以我的项目结构是:

src/debug/java/

src/main/java/

src/release/java/
Run Code Online (Sandbox Code Playgroud)

我有CartActivity。该类对于release版本和debug版本有不同的实现。所以这个类的位置位于两个文件夹中:

src/debug/java/activityCartActivity
src/main/java/activityCartActivity
Run Code Online (Sandbox Code Playgroud)

但是当我构建项目时gradlew assemble出现错误:

> Task :scanlib:processDebugJavaRes NO-SOURCE
> Task :scanlib:transformClassesAndResourcesWithPrepareIntermediateJarsForDebug
> Task :app:javaPreCompileDebug FROM-CACHE

> Task :app:compileDebugJavaWithJavac FAILED
\app\src\debug\java\com\myproject\app\cart\CartActivity.java:66: error: duplicate class: com.myproject.app.cart.CartActivity
public class CartActivity extends AppCompatActivity {
Run Code Online (Sandbox Code Playgroud)

android-gradle-plugin

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

“使用 SMS Retriever API 自动短信验证”与“使用电话号码通过 Firebase 进行身份验证”

在我的 andoird 应用程序上进行自动短信验证我可以使用这个:

“使用 SMS Retriever API 进行自动 SMS 验证”

https://developers.google.com/identity/sms-retriever/overview

好的。

但要进行自动短信验证,我还可以使用 Firebase:

“使用电话号码在 Android 上通过 Firebase 进行身份验证”

https://firebase.google.com/docs/auth/android/phone-auth

这两种方法有什么区别?

android firebase-authentication sms-verification

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

在 MaterialCardView 的中心设置自定义图标

我无法在 MaterialCardView 的中心设置自定义图标。这是我的 xml 布局

<androidx.constraintlayout.widget.ConstraintLayout
    android:id="@+id/cardPaymentContainer"
    android:layout_width="0dp"
    android:layout_height="200dp"
    android:layout_margin="@dimen/default_margin"
    android:layout_marginStart="@dimen/button_margin"
    android:layout_marginEnd="@dimen/button_margin"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/toolBarContainer">

    <com.google.android.material.card.MaterialCardView
        android:id="@+id/cardPaymentCardView"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:checkable="true"
        android:clickable="true"
        android:focusable="true"
        app:cardCornerRadius="@dimen/card_view_cornder_radius"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">
    </com.google.android.material.card.MaterialCardView>

</androidx.constraintlayout.widget.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)

处理点击活动:

dataBinding =
            DataBindingUtil.setContentView<PaymentActivityBinding>(this, R.layout.payment_activity)
        dataBinding.setHandler(this)
        dataBinding.cardPaymentCardView.setOnClickListener({
            Debug.d(TAG, "cardPaymentCardView: onClick")
            dataBinding.cardPaymentCardView.isChecked = !dataBinding.cardPaymentCardView.isChecked
        })
Run Code Online (Sandbox Code Playgroud)

这里的结果:

未点击:

在此处输入图片说明

并点击:

在此处输入图片说明

但我需要将我的自定义图标放在 CardView 的中心。像这样:

在此处输入图片说明

我将 SVG 转换为 xml(通过 Android Studio)

我试试这个,但图标没有显示,也没有显示在cardView的中心:

 <com.google.android.material.card.MaterialCardView
                android:id="@+id/cardPaymentCardView"
                style="@style/cardViewStyle"
                android:layout_width="0dp"
                android:layout_height="0dp"
                android:checkable="true"
                android:clickable="true"
                android:focusable="true"
                app:cardCornerRadius="@dimen/card_view_cornder_radius"
                app:checkedIcon="@drawable/ic_credit_card_outline_select"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent">

            </com.google.android.material.card.MaterialCardView>
Run Code Online (Sandbox Code Playgroud)

android material-design android-cardview material-components material-components-android

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

无法写入 JSON:JsonObject;嵌套异常是 com.fasterxml.jackson.databind.JsonMappingException: JsonObject

弹簧靴 2.5

    @PostMapping("/cart/product")
    public Response addProduct(@RequestBody Map<String, Object> payloadMap) {
        logger.info("addProduct: payloadMap: " + payloadMap);
        String userName = payloadMap.get("user_name").toString();
        final Product product = new ObjectMapper().convertValue(payloadMap.get("product"), Product.class);
        int quantity = (int) payloadMap.get("quantity");
        Cart findCart = cartRepository.findByUsername(userName);
        if (findCart == null) {
            Cart cart = new Cart();
            cart.setCreated(new Date());
            cart.setUsername(userName);
            cart.addProduct(product, quantity);
            cartRepository.save(cart);
            logger.info("addProduct: success_add_product_to_new_cart: " + cart);
            return ResponseService.getSuccessResponse(GsonUtil.gson.toJsonTree(cart));
        } else {
            findCart.addProduct(product, quantity);
            logger.info("addProduct: before_save_exist_cart: " + findCart);
            cartRepository.save(findCart);
            logger.info("addProduct: success_add_product_to_exist_cart: " + findCart);
            return ResponseService.getSuccessResponse(GsonUtil.gson.toJsonTree(findCart));
        }
    }


public class …
Run Code Online (Sandbox Code Playgroud)

gson spring-boot

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

SpringBoot - 无法解析 @RunWith - 找不到符号

SpringBoot 项目。

在 build.gradle 中:

dependencies {
    implementation 'com.google.code.gson:gson:2.7'
    implementation 'com.h2database:h2'
    implementation 'org.springframework.boot:spring-boot-starter'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-jdbc'
    implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.8.0'
    implementation('com.squareup.retrofit2:retrofit:2.4.0')
    implementation('com.squareup.retrofit2:converter-gson:2.4.0')
    implementation group: 'javax.validation', name: 'validation-api', version: '2.0.1.Final'

    testImplementation('org.springframework.boot:spring-boot-starter-test') {
        exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
    }
}

test {
    useJUnitPlatform()
}
Run Code Online (Sandbox Code Playgroud)

这是我的测试课:

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager;
import org.springframework.test.context.junit4.SpringRunner;

import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;

@RunWith(SpringRunner.class)
@DataJpaTest
public class CategoryRepositoryIntegrationTest {
    @Autowired
    private TestEntityManager entityManager;
    @Autowired
    private CategoryRepository productRepository;
Run Code Online (Sandbox Code Playgroud)

但我得到错误:

error: cannot find symbol

@RunWith(SpringRunner.class)
 ^ …
Run Code Online (Sandbox Code Playgroud)

build.gradle spring-boot

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