小编cav*_*llo的帖子

未安装JDK 8 - 错误404:未找到

从昨天起,我一直在尝试在我的Ubuntu机器上安装JDK8,但它一直在失败.

我一直在尝试运行命令:

sudo add-apt-repository ppa:webupd8team/java -y
sudo apt-get update
sudo apt-get install oracle-java8-installer
sudo apt-get install oracle-java8-set-default
Run Code Online (Sandbox Code Playgroud)

但是我无法继续,因为在运行命令时,sudo apt-get install oracle-java8-installer我得到的是:

...
Connecting to download.oracle.com (download.oracle.com)|23.215.130.99|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2017-10-18 11:07:34 ERROR 404: Not Found.

download failed
Oracle JDK 8 is NOT installed.
dpkg: error processing package oracle-java8-installer (--configure):
 subprocess installed post-installation script returned error exit status 1
...
Run Code Online (Sandbox Code Playgroud)

我的安装程序是64位Ubuntu 14.04.

java ubuntu java-8

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

Google Play服务泄漏

我刚开始使用Google Play游戏服务,昨天在检查logcat时我无法注意到这个错误:

E/DataBuffer(3183):检测到DataBuffer对象内部数据泄漏!确保在完成所有DataBuffer扩展对象后显式调用close().(内部对象:com.google.android.gms.common.data.DataHolder@40555410)

它连续发生几次.我不完全确定它为什么会出现.它不会使我的应用程序崩溃,也不会使谷歌成就/排行榜功能停止工作.

我所知道的是它与"unlockAchievementImmediate"和"submitScoreImmediate"功能有关.

有没有人遇到此问题或有任何建议?


编辑:在我的应用程序中,我只使用"unlockAchievementImmediate"和"submitScoreImmediate".这些函数不返回任何需要关闭的缓冲区.

android memory-leaks google-play-services google-play-games

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

对于bcrypt和db-migrate,NodeJS 4和5 npm安装失败

前段时间我安装了NodeJS(v0.10.31)并且没有遇到任何问题,但是最近我决定更新到Node v5.0.0.一切都很好,直到我决定使用bcrypt和db-migrate.调用命令npm install将无法吐出一长串详细信息,但没有关于该问题的明确信息:

$ sudo npm install

> bcrypt@0.8.5 install /home/cavpollo/intuitiva/cirio/cirio-id/node_modules/bcrypt
> node-gyp rebuild

make: Entering directory `/home/cavpollo/intuitiva/cirio/cirio-id/node_modules/bcrypt/build'
  CXX(target) Release/obj.target/bcrypt_lib/src/blowfish.o
  CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt.o
  CXX(target) Release/obj.target/bcrypt_lib/bcrypt_node/src.o
In file included from /home/cavpollo/.node-gyp/5.0.0/include/node/node.h:42:0,
                 from ../node_modules/nan/nan.h:24,
                 from ../src/bcrypt_node.cc:1:
/home/cavpollo/.node-gyp/5.0.0/include/node/v8.h:336:1: error: expected unqualified-id before ‘using’
/home/cavpollo/.node-gyp/5.0.0/include/node/v8.h:469:1: error: expected unqualified-id before ‘using’
/home/cavpollo/.node-gyp/5.0.0/include/node/v8.h:856:1: error: expected unqualified-id before ‘using’
In file included from ../node_modules/nan/nan.h:184:0,
                 from ../src/bcrypt_node.cc:1:
../node_modules/nan/nan_maybe_43_inl.h:13:1: error: expected unqualified-id before ‘using’
../node_modules/nan/nan_maybe_43_inl.h:16:1: error: expected unqualified-id before ‘using’
../node_modules/nan/nan_maybe_43_inl.h:19:12: error: ‘Maybe’ does not name a type …
Run Code Online (Sandbox Code Playgroud)

ubuntu gcc node.js npm npm-install

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

配置 kapt 以处理 lombok 注释

这是对这些问题的跟进:

似乎 kapt 已经发展了,现在它甚至在 Maven 中得到支持。我正在尝试这个(注意配置中的 Lombok 注释处理器):

       <plugin>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-maven-plugin</artifactId>
            <version>${kotlin.version}</version>
            <executions>
                <execution>
                    <id>kapt</id>
                    <goals>
                        <goal>kapt</goal>
                    </goals>
                    <configuration>
                        <sourceDirs>
                            <sourceDir>${project.basedir}/src/main/java</sourceDir>
                            <sourceDir>${project.basedir}/src/main/kotlin</sourceDir>
                        </sourceDirs>
                        <annotationProcessors>
                            <annotationProcessor>lombok.core.AnnotationProcessor</annotationProcessor>
                        </annotationProcessors>
                    </configuration>
                </execution>
                ...
       </plugin>
Run Code Online (Sandbox Code Playgroud)

但它似乎仍然没有效果,而且 Lombok@Getter仍然被忽略,如相关问题中所述。

有什么可以做的吗?

lombok kotlin kapt

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

如何在自定义验证注释上插入 ConstraintValidator 消息

我已经阅读了一些关于如何使用 Hibernate 的 ConstrainValidator 的问答和指南(如Hibernate 文档),但他们都没有明确提到在创建自己的自定义验证注释时如何在验证错误消息的特定位置插入值。

例如,如果我有一条如下所示的验证错误消息:

foo.bar.error=This value '{myValue}' is wrong.
Run Code Online (Sandbox Code Playgroud)

如果验证失败,我想获得以下消息:

值“一些错误的值”是错误的。

验证将像这样使用:

public class SomeClass {

    @CustomAnnotation(message="{foo.bar.error}")
    public MyObject myObject;

    ...

}

public class MyObject {
    private String myValue;

    ...
}
Run Code Online (Sandbox Code Playgroud)

java hibernate-validator

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

在 NodeJS 上同时接收相同名称输入和多部分/表单数据输入作为数组和文件附件

我在使用enctype 时遇到一些麻烦,multipart/form-data同时发送具有相同名称的输入以作为数组获取。我似乎只能获取上传的图像或数组输入,但不能同时获取两者......

例如,我有这样的表格:

<form method="post" action="/test">
  <input name="testinput" value="valueA">
  <input name="testinput" value="valueB">
  <input type="file" name="fileattachment">
  <input type="submit" value="Submit">
</form>
Run Code Online (Sandbox Code Playgroud)

如果我将表单的 enctype 设置为multipart/form-data,如下所示:

<form method="post" action="/test" enctype="multipart/form-data">
Run Code Online (Sandbox Code Playgroud)

我最终在 NodeJS 应用程序中很好地收到了“文件附件”,但我只获得了“testinput”的最后一个值,如下所示:

//req.body
//---
{
    testinput: 'valueB' // I'm missing valueA!
}

//req.files
//---
{
    fileattachment: { 
        name: 'biglogo.png',
        data: <Buffer 89 ... >,
        encoding: '7bit',
        mimetype: 'image/png',
        mv: [Function] 
    }
}
Run Code Online (Sandbox Code Playgroud)

如果未设置 enctype,“testinput”数据将作为数组出现,但“fileattachment”会丢失,我只能获取上传文件的名称,如下所示:

//req.body
//---
{
    testinput: ['valueA', 'valueB'],
    fileattachment: 'some_picture.png' // Useless for file uploading
}
Run Code Online (Sandbox Code Playgroud)

我认为这与我设置express'主体解析器的方式有关,但我似乎无法找出正确的配置。这是我的设置(针对相关代码进行了简化): …

forms file-upload input node.js express

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

Spring - 在 Ajax 请求失败后成功登录后重定向到链接

我有一个网站,需要根据用户操作在元素内异步呈现一些 HTML。如果用户的会话过期,事情会变得棘手,但可以通过创建一个自定义AuthenticationEntryPoint类来解决这个问题,比如这个 SO 问题这个 SO 问题建议。

我的问题在用户重新登录后出现,因为用户被重定向到最后一个请求的 URL,这恰好是 Ajax 请求,因此我的用户被重定向到 HTML 的片段,而不是它浏览的最后一个页面。

我能够通过删除自定义上的会话属性来解决这个问题AuthenticationEntryPoint

if (ajaxOrAsync) {
    request.getSession().removeAttribute("SPRING_SECURITY_SAVED_REQUEST");
}
Run Code Online (Sandbox Code Playgroud)

我的问题来了。

虽然前面的代码解决了我的问题,但它具有将用户重定向到主页而不是它浏览的最后一页的副作用(因为没有保存的请求)。这不是什么大问题,但它会使网站不一致,因为如果最后一个请求是异步请求,它会被重定向到主页,但如果是正常请求,它会被重定向到最后浏览的页面。=(

我设法编码它来处理这种情况:

import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.PortResolver;
import org.springframework.security.web.PortResolverImpl;
import org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint;
import org.springframework.security.web.savedrequest.DefaultSavedRequest;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;

import static javax.servlet.http.HttpServletResponse.SC_UNAUTHORIZED;
import static org.apache.commons.lang.StringUtils.isBlank;

public class CustomAuthenticationEntryPoint extends LoginUrlAuthenticationEntryPoint {
    ... // Some not so relevant code

    @Override
    public void commence(final HttpServletRequest request, …
Run Code Online (Sandbox Code Playgroud)

ajax spring spring-mvc spring-security

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

使用 Spring JmsListener 的扩展客户端库的 Amazon SQS 异步侦听器

我的团队正在尝试为Amazon SQS Java 扩展客户端库实现异步侦听器,因为如链接和链接所述,短期内不会提供任何支持。

最初的问题是我们需要通过SQS发送非常大的有效负载。因此,为了解决这个问题,我们使用了前面提到的 Amazon SQS Java 扩展客户端库功能。它会自动将大量有效负载上传到 S3,然后将它们作为消息检索,而消费者无需担心如何从 S3 检索它们。遗憾的是,这只能开箱即用地同步完成。

因此,为了使其异步工作,我们使用JmsListener编写了以下代码。它起作用了,我们获得了 String 格式的序列化对象。

AWS/SQS Bean

import com.amazon.sqs.javamessaging.AmazonSQSExtendedClient;
import com.amazon.sqs.javamessaging.ExtendedClientConfiguration;
import com.amazon.sqs.javamessaging.ProviderConfiguration;
import com.amazon.sqs.javamessaging.SQSConnectionFactory;
import com.amazonaws.auth.AWSCredentialsProvider;
import com.amazonaws.auth.DefaultAWSCredentialsProviderChain;
import com.amazonaws.services.s3.AmazonS3Client;
import com.amazonaws.services.sqs.AmazonSQSAsync;
import org.springframework.jms.config.DefaultJmsListenerContainerFactory;
import org.springframework.jms.config.JmsListenerContainerFactory;

@Configuration
public class AWSConfig {

    @Bean
    public AWSCredentialsProvider awsCredentialsProvider() {
        return new DefaultAWSCredentialsProviderChain();
    }

    @Bean
    public JmsListenerContainerFactory<?> jmsListenerContainerFactory(ConnectionFactory connectionFactory) {
        final DefaultJmsListenerContainerFactory jmsListenerContainerFactory = new DefaultJmsListenerContainerFactory();
        jmsListenerContainerFactory.setConnectionFactory(connectionFactory);

        return jmsListenerContainerFactory;
    }

    @Bean
    public ConnectionFactory connectionFactory(final AmazonS3Client amazonS3Client, final …
Run Code Online (Sandbox Code Playgroud)

java asynchronous listener amazon-sqs spring-jms

5
推荐指数
0
解决办法
2146
查看次数

在 Spring 上,如何使用 JPA 和组合键(分区键和排序键)查询 DynamoDB 表?

我有一个使用 JPA 和 Spring Data DynamoDB 设置的 Spring 项目。工作正常。我可以通过按分区键和排序键(称为DynamoDBHashKeyDynamoDBRangeKey)读取 DynamoDB 表来获取项目。

我的问题是,我的存储库的设置方式是使用queryandscan操作读取表,而不是get-item操作,这应该更有效。

这是我的实体:

import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAttribute;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBHashKey;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.data.annotation.Id;

@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@DynamoDBTable(tableName = "my-entity-table")
public class MyEntity {

    @Id
    @DynamoDBHashKey 
    @DynamoDBAttribute(attributeName = "partition_key")
    private String partitionKey;

    @Id
    @DynamoDBRangeKey
    @DynamoDBAttribute(attributeName = "sort_key")
    private String sortKey;

    ...
}
Run Code Online (Sandbox Code Playgroud)

这是我的存储库:

import org.socialsignin.spring.data.dynamodb.repository.EnableScan;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

import java.util.List; …
Run Code Online (Sandbox Code Playgroud)

java spring jpa spring-data-jpa amazon-dynamodb

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

NodeJS db-migrate TypeError:无法读取null的属性"1"

我刚刚将nodejs包db-migrate安装到现有的nodejs项目中.似乎在与DB的连接方面正确配置了所有内容.

Database.json:

{
    "development": "postgres://blabla",
    "production": "postgres://blabla"
}
Run Code Online (Sandbox Code Playgroud)

移民:

var dbm = global.dbm || require('db-migrate');
var type = dbm.dataType;

exports.up = function(db, callback) {
    db.createTable('users', {
        id: { type: 'int', primaryKey: true, autoIncrement: true },
        username: { type: 'string', unique: true }
        }, callback);
};

exports.down = function(db, callback) {
    db.dropTable('users', callback);
};
Run Code Online (Sandbox Code Playgroud)

每当我尝试运行时db-migrate up(使用指定数据库文件,迁移,迁移次数等参数的任何变化),该命令每次都会引发错误:

[ERROR] TypeError: Cannot read property '1' of null
   at Class.extend.parseName (C:\Users\test\Projects\nodejs\cirio-crm\node_modules\db-migrate\lib\skeleton.js:162:17)
   at Class.Skeleton.extend.init (C:\Users\test\Projects\nodejs\cirio-crm\node_modules\db-migrate\lib\migration.js:35:24)
   at Class.prototype.(anonymous function) [as init] (C:\Users\test\Projects\nodejs\cirio-crm\node_modules\db-migrate\lib\class.js:36:24)
   at new Class …
Run Code Online (Sandbox Code Playgroud)

dbmigrate node.js npm

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