小编Pan*_*ciz的帖子

Maven shade插件包装DLL

我必须在我的项目中添加一个JNI模块.

我在Maven中安装模块作为两个不同的工件:jar库:

mvn install:install-file -DgroupId=com.test -DartifactId=ssa -Dversion=1.0 -Dpackaging=jar -Dfile=ssa.jar
Run Code Online (Sandbox Code Playgroud)

和带有DLL的运行时库

mvn install:install-file -DgroupId=com.sirio -Dpackaging=ddl -DartifactId=ssa-runtime -classifier=windows-x86 -Dversion=1.0 -Dfile=SSADll.dll
Run Code Online (Sandbox Code Playgroud)

在我的maven项目中,我添加了这些依赖:

    <dependency>
        <groupId>com.test</groupId>
        <artifactId>ssa</artifactId>
        <version>1.0</version>
    </dependency>
    <dependency>
        <groupId>com.test</groupId>
        <artifactId>ssa-runtime</artifactId>
        <classifier>windows-${arch}</classifier>
        <type>dll</type>
        <version>1.0</version>
        <scope>runtime</scope>
    </dependency>
Run Code Online (Sandbox Code Playgroud)

我的问题是当我运行shade插件目标来创建一个带有依赖项的jar时,我得到错误:

Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:2.3:shade (default) on project ....: Error creating shaded jar: error in opening zip file sirio\ssa-runtime\1.0\ssa-runtime-1.0-windows-x86.dll 
Run Code Online (Sandbox Code Playgroud)

如何告诉shade插件不要解压缩dll?

java dll maven

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

使用Foreach Lambda中的前一个元素的Java流

我有一些0s内部数字列表.由于0在我的情况下意味着无效的度量,我需要0使用我在前面的位置中找到的第一个非0元素来更改值元素.

例如列表

45 55 0 0 46 0 39 0 0 0
Run Code Online (Sandbox Code Playgroud)

必须成为

45 55 55 55 46 46 39 39 39 39
Run Code Online (Sandbox Code Playgroud)

这是使用经典的实现 for each

      int lastNonZeroVal = 0;
        for (MntrRoastDVO vo : res) {
            if (vo.getValColor() > 0) {
                lastNonZeroVal = vo.getValColor();
            } else {
                vo.setValColor(lastNonZeroVal);
            }
        }
Run Code Online (Sandbox Code Playgroud)

有没有办法用Java Streams和Lambda函数实现它?

因为我知道我不能在foreach lambda中更改流的源,实际上列表是对象列表,我不会更改列表的元素,但我只是分配新值.

这是我的第一个解决方案

int lastNonZeroVal = 1;
resutl.stream().forEach(vo -> {
        if(vo.getValColor()>0){
            lastNonZeroVal=vo.getValColor();
        }else{
            vo.setValColor(lastNonZeroVal);
        }
});
Run Code Online (Sandbox Code Playgroud)

但我也在这里读到

最好将lambdas传递给流操作完全没有副作用.也就是说,它们不会在执行期间改变任何基于堆的状态或执行任何I/O.

这让我很担心

数据是分区的,不能保证在处理给定元素时,已经处理了该元素之前的所有元素. …

java lambda

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

Spring Boot 使用 Yaml 而不是属性文件

我使用Spring Boot。我想使用 YAML 而不是属性来编写配置。

由于我使用的spring-boot-starterSnakeYAML 库已经在类路径中,并且 SpringApplication 应该自动使用 YAML 版本。

只要您的类路径上有 SnakeYAML 库,SpringApplication 类就会自动支持 YAML 作为属性的替代方案。

问题是应用程序继续使用 application.properties 文件,如果我删除它,则根本不会加载任何配置。

有人能帮我吗?这是我的主文件

@SpringBootApplication
public class App {


    public static void main(String[] args) throws Exception {
        SpringApplication app = new SpringApplication(App.class);
        app.setBannerMode(Banner.Mode.OFF);
        app.run(args);
    }
}
Run Code Online (Sandbox Code Playgroud)

这是我的pom.xml

....
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.4.0.RELEASE</version>
    </parent>

    <dependencies>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>
Run Code Online (Sandbox Code Playgroud)

application.yml 文件只是

tasks: …
Run Code Online (Sandbox Code Playgroud)

java spring yaml spring-boot

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

数据绑定不适用于大写字母包名称

我有一个Android项目,它的包名称有点像这个com.example.MyPackage,其中asMyPackage有两个大写字母MP,由于它们我无法使用数据绑定。

当我添加数据绑定并构建我的项目时,它说无法猜测名称。我发现在 stackover flow 上有人讨论这是因为包名称中有大写字母。

java android 2-way-object-databinding kotlin package-name

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

Bigquery STRING 数组到 INT 数组

我试图从一个列中提取标准 SQL 中的INT64s数组,BigQuery该列是一长串由逗号分隔的数字(例如,2013,1625,1297,7634)。我可以通过以下方式轻松拉出一系列字符串:

SELECT
  SPLIT(string_col,",")
FROM
  table
Run Code Online (Sandbox Code Playgroud)

但是,我想返回一个INT64s数组,而不是一个字符串数组。我怎样才能做到这一点?我试过了

CAST(SPLIT(string_col,",") AS ARRAY<INT64>) 
Run Code Online (Sandbox Code Playgroud)

但这不起作用。

google-bigquery

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

Android Studio Run Emulator在linux上失败

我试图从Android Studio 2.3.3(在Linux机器上)运行Android模拟器,但如果失败没有错误(我尝试使用x86图像API 24).

所以我尝试从控制台运行

 /opt/android/android-sdk-linux/tools/emulator @Nexus_5_API_24 
Run Code Online (Sandbox Code Playgroud)

我收到这个错误

libGL error: unable to load driver: i965_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: i965
libGL error: unable to load driver: i965_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: i965
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
X Error of failed request:  GLXBadContext
Run Code Online (Sandbox Code Playgroud)

我在这里发现运行-use-system-libs选项可以解决问题

我的问题是如何添加此参数以通过Android Studio运行模拟器?如何在从终端运行的模拟器上从Android Studio启动我的应用程序?现在我收到了这个错误:

com.android.ddmlib.AdbCommandRejectedException: device unauthorized.
This adb server's …
Run Code Online (Sandbox Code Playgroud)

android android-emulator android-studio

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

itext for android和lint错误

我为我的项目添加android的android库的itext,一切正常但是当我使用gradle lint构建我的项目时会生成此错误:

InvalidPackage: Package not included in Android
../../libs/itextg-5.5.3.jar: Invalid package reference in library; not included in Android: java.awt. Referenced from com.itextpdf.text.pdf.BarcodeCodabar.
../../libs/itextg-5.5.3.jar: Invalid package reference in library; not included in Android: java.awt.image. Referenced from com.itextpdf.text.pdf.BarcodeCodabar.
../../libs/itextg-5.5.3.jar: Invalid package reference in library; not included in Android: javax.management. Referenced from com.itextpdf.testutils.ITextTest.
../../libs/itextg-5.5.3.jar: Invalid package reference in library; not included in Android: javax.xml.crypto.dom. Referenced from com.itextpdf.text.pdf.security.MakeXmlSignature.
../../libs/itextg-5.5.3.jar: Invalid package reference in library; not included in Android: javax.xml.crypto.dsig. Referenced from com.itextpdf.text.pdf.security.MakeXmlSignature.
Run Code Online (Sandbox Code Playgroud)

压制并忽略此错误是否安全?

我下载了最新的android …

android lint itext gradle

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