小编nll*_*dfx的帖子

AAPT错误无休止的gradle建设

我在Ubuntu 16.04 x64上安装了Android Studio.当开始新项目时,我得到了未解决的"R" setContentView(R.layout.activity_main);.gradle输出也说:

Configuration on demand is an incubating feature.
Incremental java compilation is an incubating feature.
:clean UP-TO-DATE
:app:clean
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAnimatedVectorDrawable2400Library
:app:prepareComAndroidSupportAppcompatV72400Library
:app:prepareComAndroidSupportSupportV42400Library
:app:prepareComAndroidSupportSupportVectorDrawable2400Library
:app:prepareDebugDependencies
:app:compileDebugAidl
:app:compileDebugRenderscript
:app:generateDebugBuildConfig
:app:mergeDebugShaders
:app:compileDebugShaders
:app:generateDebugAssets
:app:mergeDebugAssets
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources
:app:mergeDebugResources
AAPT err(Facade for 31820177): /home/nllsdfx/Downloads/build-tools/24.0.0/aapt: 5: /home/nllsdfx/Downloads/build-tools/24.0.0/aapt: Syntax error: end of file unexpected (expecting ")")
AAPT err(Facade for 10308796): /home/nllsdfx/Downloads/build-tools/24.0.0/aapt: 5: /home/nllsdfx/Downloads/build-tools/24.0.0/aapt: Syntax error: end of file unexpected (expecting ")")
AAPT err(Facade for 25000613): …
Run Code Online (Sandbox Code Playgroud)

android android-gradle-plugin

6
推荐指数
1
解决办法
2108
查看次数

使用 liquibase 创建 Postgres 数据库

我正在尝试使用liqubase创建一个空数据库。我使用这种方法来做到这一点,但问题是它对我不起作用。

我使用 Postgresql 10,并且有我的 Maven 和 liqubase 配置:

 <plugin>
          <groupId>org.liquibase</groupId>
          <artifactId>liquibase-maven-plugin</artifactId>
          <version>3.0.5</version>
          <configuration>
             <propertyFile>src/main/resources/liquibase/liquibase.properties</propertyFile>
          </configuration>
          <executions>
              <execution>
                    <phase>process-resources</phase>
                    <goals>
                        <goal>update</goal>
                    </goals>
              </execution>
          </executions>
  </plugin>
Run Code Online (Sandbox Code Playgroud)

和我的liqubase.properties

changeLogFile=src/main/resources/liquibase/db.changelog.xml
driver=org.postgresql.Driver
dropFirst=false
url=jdbc:postgresql://localhost:5432/auth?createDatabaseIfNotExist=true
username=postgres
password=root
Run Code Online (Sandbox Code Playgroud)

上的错误mvn clean package是:

org.postgresql.util.PSQLException:致命:数据库“auth”不存在

java liquibase maven

6
推荐指数
1
解决办法
9759
查看次数

Gitlab CI:找不到 docker

我正在尝试使用 gitlab ci feature 构建我的项目。根据这个问题,我已经正确地完成了一切。这是我的 .gitlab-ci.yml。

.gitlab-ci.yml

image: docker:latest

services:
  - docker:dind

stages:
  - build
  - release
  - deploy

variables:
  DOCKER_DRIVER: overlay
  MAVEN_CLI_OPTS: "-s .m2/settings.xml --batch-mode"

cache:
  paths:
    - .m2/repository/
    - auth/target/

before_script:
  - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY

build:
  image: maven:latest
  stage: build
  script:
      - mvn $MAVEN_CLI_OPTS package

auth-release:
  stage: release
  when: on_success
  script:
    - docker build -f auth/Dockerfile -t "$CI_REGISTRY/$CI_PROJECT_PATH/auth" ./auth
    - docker push "$CI_REGISTRY/$CI_PROJECT_PATH/auth"
Run Code Online (Sandbox Code Playgroud)

但控制台打印出错误:

控制台输出

Running with gitlab-runner 11.7.0-rc1 (6e20bd76)
  on docker-auto-scale …
Run Code Online (Sandbox Code Playgroud)

continuous-integration gitlab docker gitlab-ci gitlab-ci-runner

6
推荐指数
1
解决办法
7158
查看次数

今天如何在 Java 8 Ubuntu 上启动 JavaFX 应用程序?

我试图启动应用程序但出现错误:

java.lang.ClassNotFoundException: com.sun.glass.ui.gtk.GtkPlatformFactory   at
  java.net.URLClassLoader.findClass(URLClassLoader.java:381)  at
  java.lang.ClassLoader.loadClass(ClassLoader.java:424)   at
  java.lang.ClassLoader.loadClass(ClassLoader.java:357)   at
  java.lang.Class.forName0(Native Method)   at
  java.lang.Class.forName(Class.java:264)   at
  com.sun.glass.ui.PlatformFactory.getPlatformFactory(PlatformFactory.java:42)
    at com.sun.glass.ui.Application.run(Application.java:146)   at
  com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:257)
    at
  com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:211)
    at
  com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:675)
    at
  com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:337)
    at
  com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  at
  sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at
  sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)   at
  sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
  Exception in thread "main" java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  at
  sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at
  sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)   at
  sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
  Caused by: java.lang.NullPointerException   at
  com.sun.glass.ui.Application.run(Application.java:146)  at
  com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:257)
    at
  com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:211)
    at
  com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:675)
    at
  com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:337)
    at
  com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
    ... 5 more 
Run Code Online (Sandbox Code Playgroud)

以及Failed to load Glass factory class …

java javafx javafx-8

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

Java 10:替换java.xml.ws冲突

我必须java.xml.ws*在我的项目中使用组件,但因为它已被弃用并且很快就会被删除我想要替换这些组件.所以我将这个依赖项添加到我的项目pom文件中:

<dependency>
    <groupId>com.sun.xml.ws</groupId>
    <artifactId>jaxws-ri</artifactId>
    <version>2.3.0</version>
    <type>pom</type>
</dependency>
Run Code Online (Sandbox Code Playgroud)

这是我的模块配置:

module x.y.z {
    requires kotlin.stdlib;
    requires spring.boot;
    requires spring.boot.autoconfigure;
    requires spring.context;
    requires cxf.core;
    requires cxf.rt.frontend.jaxws;
    requires java.xml.ws;
}
Run Code Online (Sandbox Code Playgroud)

但是有一个错误:

在此输入图像描述

它是什么意思以及如何修复它以便我可以使用上面的依赖而不是java.xml.wsjdk?

java java-10

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

Kotlin函数重载(varargs vs单参数)

我有两个函数检查String/Strings是否为空.

fun isBlank(s: String?) : Boolean {
            return s.isNullOrBlank()
        }

fun isBlank(vararg strings: String) : Boolean {
            return strings.isEmpty() ||
                    strings.any { isBlank(it) }
        }
Run Code Online (Sandbox Code Playgroud)

所以我尝试从第二个函数调用第一个函数,但似乎它试图调用自己.例如,它在java中很好用:

public static boolean isBlank(final String string) {
        return string == null || string.trim().isEmpty();
}

public static boolean isBlank(final String... strings) {
        return strings.length == 0
                || Arrays.stream(strings).anyMatch(StringUtil::isBlank);
}
Run Code Online (Sandbox Code Playgroud)

如何在kotlin处理这种情况?

overloading variadic-functions kotlin

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

Kotlin Exposed:如何创建准备好的语句或避免 SQL 注入?

我使用 Kotlin Exposed 创建查询。但是当我必须使用从客户端收到的参数时遇到了一个问题:

private fun accountInfo(msg: AccountInfoMsg) {
        transaction {
            val accountInfo = UserAccount.wrapRow(Account.innerJoin(Account_Banned).select {
                Account.email.eq(msg.login.toLowerCase()) and (Account.id eq Account_Banned.accountId)
            }.single())
        }
    }
Run Code Online (Sandbox Code Playgroud)

那么如何创建一个准备好的语句或者如何通过可能的 SQL 注入传递参数呢?

kotlin kotlin-exposed

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

Kotlin:捕获扩展

因为 Kotlincatch不像 java 那样支持多个,所以我想创建扩展来部分解决问题。

fun <T: Throwable>  (() -> Unit).catch(vararg exceptions: KClass<T>, catchBlock: (Throwable) -> Unit) {
    try {
        this()
    } catch (e: Throwable) {
        if (e::class in exceptions) catchBlock(e) else throw e
    }
}
Run Code Online (Sandbox Code Playgroud)

可以这样调用:

{
  throw NotImplementedException.exception()
}.catch(NotImplementedException::class) {
   //handle it
}
Run Code Online (Sandbox Code Playgroud)

但问题是,如果传递多个不同类型的参数,它不起作用(类型推断失败):

{
   throw IndexOutOfBoundsException()
}.catch(NotImplementedException::class, IndexOutOfBoundsException::class) {

}
Run Code Online (Sandbox Code Playgroud)

那么如何更改扩展的签名以捕获多个不同类型的异常呢?

exception-handling exception kotlin

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

JavaFX:父项及其子项的“鼠标单击”事件

我有一张卡,它由页眉,正文和页脚组成,可以由更多节点组成,例如标签,文本字段等。

on mouse clicked卡内发生单击时,无论何时是卡本身还是它的子代之一,我都需要捕捉事件。现在,如果我单击文本字段,则不会触发事件。

private StackPane newCard() {
        //card wrapper
        StackPane card = new StackPane();
        VBox cardContent = new VBox();

        JFXDepthManager.setDepth(card, 1);
        //Header
        StackPane header = new StackPane();

        VBox headerContent = new VBox();
        header.getChildren().add(headerContent);
        Label label = new Label("Card title");

        //if I click this text field, event is not triggered
        TextField groupCode = new TextField();

        headerContent.getChildren().addAll(label, groupCode);

        //body
        StackPane body = new StackPane();


        //footer
        StackPane footer = new StackPane();


        cardContent.getChildren().addAll(header, body, footer);
        card.getChildren().add(cardContent);

        //event
        card.setOnMouseClicked(event -> System.out.println("Clicked!")); …
Run Code Online (Sandbox Code Playgroud)

java javafx

0
推荐指数
1
解决办法
1804
查看次数