小编bac*_*chr的帖子

实现Spring Data存储库的自定义方法并通过REST公开它们

我正在尝试将自定义方法添加到我的Spring Data存储库PersonRepository,如1.3 Spring Data存储库的自定义实现中所述,并通过REST公开这些方法.初始代码来自使用REST示例访问JPA数据,以下是添加/修改类的代码:

interface PersonRepositoryCustom {
  List<Person> findByFistName(String name);
}

class PersonRepositoryImpl implements PersonRepositoryCustom, InitializingBean {
  @Override
  public void afterPropertiesSet() throws Exception {
    // initialization here
  }
  @Override
  public List<Person> findByFistName(String name) {
    // find the list of persons with the given firstname
  }
}

@RepositoryRestResource(collectionResourceRel = "people", path = "people")
public interface PersonRepository extends PagingAndSortingRepository<Person, Long> {
  List<Person> findByLastName(@Param("name") String name);  
}
Run Code Online (Sandbox Code Playgroud)

当我运行应用程序并访问时http://localhost:8080/portfolio/search/,我得到以下响应正文:

{
  "_links" : {
    "findByLastName" …
Run Code Online (Sandbox Code Playgroud)

java rest spring jpa spring-data

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

正确安装java 8和java 7

我在我的Windows 7机器上安装了JDK 1.7,安装JDK 1.8 u20后,我遇到以下错误:

C:\>java -version
Error: Registry key 'Software\JavaSoft\Java Runtime Environment'\CurrentVersion'
has value '1.8', but '1.7' is required.
Error: could not find java.dll
Error: Could not find Java SE Runtime Environment.
Run Code Online (Sandbox Code Playgroud)

我的PATH变量指向旧版本(即1.7).

这里有什么问题以及我如何使用java 8和java 7?

java java-7 java-8

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

无法处理配置类的导入候选项

我有一个Spring Boot项目,我可以在IntelliJ中成功运行,但是当我打包一个可执行jar时,我再也无法运行它了.这是异常的堆栈跟踪:

18:13:55.254 [main] INFO  o.s.c.a.AnnotationConfigApplicationContext - Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@b3d7190: startup date [Wed Sep 07 18:13:55 CEST 2016]; root of context hierarchy
18:13:55.403 [main] WARN  o.s.c.a.AnnotationConfigApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [el.dorado.App]; nested exception is java.lang.IllegalArgumentException: No auto configuration classes found in META-INF/spring.factories. If you are using a custom packaging, make sure that file is correct.
18:13:55.414 [main] ERROR o.s.boot.SpringApplication - Application startup failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to …
Run Code Online (Sandbox Code Playgroud)

java spring maven spring-data-jpa spring-boot

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

golang将一个字符串添加到切片... interface {}

我有一个作为参数的方法v ...interface{},我需要在前面添加一个string.这是方法:

func (l Log) Error(v ...interface{}) {
  l.Out.Println(append([]string{" ERROR "}, v...))
}
Run Code Online (Sandbox Code Playgroud)

当我尝试使用append()它不起作用:

> append("some string", v)
first argument to append must be slice; have untyped string
> append([]string{"some string"}, v)
cannot use v (type []interface {}) as type string in append
Run Code Online (Sandbox Code Playgroud)

在这种情况下,前置的正确方法是什么?

arrays go slice prepend

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

如何使用PIL将通道图像合并为一张RGB图像?

我有多个 PNG 图像文件,每个通道一个:红色、绿色、蓝色和黄色。

我如何将它们合并到一个 RBGA 图像中?

到目前为止我尝试了以下方法

from PIL import Image

red    = Image.open('red.png')
green  = Image.open('green.png')
blue   = Image.open('blue.png')
yellow = Image.open('yellow.png')
rgb = Image.new('RGB', (blue.width, blue.height))
for im in [red, green, blue, yellow]:
    rgb.paste(im, (0, 0))
rgb
Run Code Online (Sandbox Code Playgroud)

显然它不起作用,因为我只是覆盖了以前的图像。有任何想法吗?

更新:由于下面的评论,事实证明我可以将红色、绿色和蓝色文件合并为:

rgb = Image.merge("RGB",(red,green,blue))
Run Code Online (Sandbox Code Playgroud)

这给出了类似以下结果: 在此输入图像描述

现在的问题是我如何使用黄色文件?

python python-imaging-library rgba python-3.x

8
推荐指数
0
解决办法
6633
查看次数

流浪客户机进入无效状态

我正在尝试在ubuntu服务器机器上设置bosh-lite(然后在本地安装cloudfoundry)(vagrant v1.6.3,Virtualbox 4.3.20r96996).当vagrant尝试使用以下错误尝试引导创建的计算机时,安装失败:

$ cd bosh-lite
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'cloudfoundry/bosh-lite' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 22 => 2222 (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: …
Run Code Online (Sandbox Code Playgroud)

ubuntu virtualbox virtual-machine cloud-foundry vagrant

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

尚未在model.summary()上建立此模型错误

我将keras模型定义如下

class ConvLayer(Layer) :
    def __init__(self, nf, ks=3, s=2, **kwargs):
        self.nf = nf
        self.grelu = GeneralReLU(leak=0.01)
        self.conv = (Conv2D(filters     = nf,
                            kernel_size = ks,
                            strides     = s,
                            padding     = "same",
                            use_bias    = False,
                            activation  = "linear"))
        super(ConvLayer, self).__init__(**kwargs)

    def rsub(self): return -self.grelu.sub
    def set_sub(self, v): self.grelu.sub = -v
    def conv_weights(self): return self.conv.weight[0]

    def build(self, input_shape):
        # No weight to train.
        super(ConvLayer, self).build(input_shape)  # Be sure to call this at the end

    def compute_output_shape(self, input_shape):
        output_shape = (input_shape[0],
                        input_shape[1]/2,
                        input_shape[2]/2,
                        self.nf) …
Run Code Online (Sandbox Code Playgroud)

python keras tensorflow tensorflow2.0

6
推荐指数
3
解决办法
5125
查看次数

在Windows上启动Zookeeper时,JAVA_HOME设置不正确

我正确地设置了zkServer.cmd在Windows上启动Zookeeper时出现"JAVA_HOME设置错误"错误!当我发出%JAVA_HOME%我得到的C:\Program Files\Java\jdk1.7.0_45是java instalation的正确目录.

我怀疑问题是由于程序文件中的空间,因为当我发出%JAVA_HOME%\bin\java.exe(zkEnv.cmd中使用的命令)时,我得到了:

'C:\Program' is not recognized as an internal or external command, operable program or batch file.
Run Code Online (Sandbox Code Playgroud)

我怎么解决这个问题?

windows command-line environment-variables java-home apache-zookeeper

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

Faillure在OSX Yosemite上推出docker

我在Mac OS X Yosemite(10.10.4)上安装Docker时遇到麻烦:当我尝试使用Docker Toolbox中的Docker Quickstart终端时,我得到了这个:

. '/Applications/Docker/Docker Quickstart Terminal.app/Contents/Resources/Scripts/start.sh'
bash-3.2$ . '/Applications/Docker/Docker Quickstart Terminal.app/Contents/Resources/Scripts/start.sh'

Creating Machine default...
executing: /usr/local/bin/VBoxManage 
STDOUT: Oracle VM VirtualBox Command Line Management Interface Version 5.0.2
(C) 2005-2015 Oracle Corporation
All rights reserved.

Usage:

  VBoxManage [<general option>] <command>

STDERR: 
Creating VirtualBox VM...
Creating SSH key...
Creating disk image...
Creating 20000 MB hard disk image...
Converting from raw image file="stdin" to file="/Users/arbi/.docker/machine/machines/default/disk.vmdk"...
Creating dynamic image with size 20971520000 bytes (20000MB)...
executing: /usr/local/bin/VBoxManage createvm --basefolder /Users/arbi/.docker/machine/machines/default --name default …
Run Code Online (Sandbox Code Playgroud)

linux macos installation docker boot2docker

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

连接到Docker容器上运行的mysql

我正在尝试在Docker(与Docker Toolbox for Mac一起安装)容器上运行mysql服务器,并从运行OS X Yosemite的机器访问它.来自官方仓库的文档没有解释如何从docker主机外部连接!!

我使用官方存储库创建了一个容器,如下所示:

$ docker pull mysql
$ docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:latest
$ docker inspect CONTAINER_ID
Run Code Online (Sandbox Code Playgroud)

然后我得到了ip地址(172.17.0.1),但是当我ping它时,我看到超时!连接到正在运行的mysql服务器的适当方法是什么?

mysql macos configuration remote-access docker

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