小编Jan*_*ert的帖子

将Docker镜像中的用户切换为非root用户

我正在尝试将用户切换到tomcat7用户以设置SSH证书.

当我这样做时su tomcat7,没有任何反应.

whoami 做完后仍然是ruturns root su tomcat7

做一个more /etc/passwd,我得到以下结果,清楚地表明tomcat7用户存在:

root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/bin/sh
bin:x:2:2:bin:/bin:/bin/sh
sys:x:3:3:sys:/dev:/bin/sh
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/bin/sh
man:x:6:12:man:/var/cache/man:/bin/sh
lp:x:7:7:lp:/var/spool/lpd:/bin/sh
mail:x:8:8:mail:/var/mail:/bin/sh
news:x:9:9:news:/var/spool/news:/bin/sh
uucp:x:10:10:uucp:/var/spool/uucp:/bin/sh
proxy:x:13:13:proxy:/bin:/bin/sh
www-data:x:33:33:www-data:/var/www:/bin/sh
backup:x:34:34:backup:/var/backups:/bin/sh
list:x:38:38:Mailing List Manager:/var/list:/bin/sh
irc:x:39:39:ircd:/var/run/ircd:/bin/sh
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/bin/sh
nobody:x:65534:65534:nobody:/nonexistent:/bin/sh
libuuid:x:100:101::/var/lib/libuuid:/bin/sh
messagebus:x:101:104::/var/run/dbus:/bin/false
colord:x:102:105:colord colour management daemon,,,:/var/lib/colord:/bin/false
saned:x:103:106::/home/saned:/bin/false
tomcat7:x:104:107::/usr/share/tomcat7:/bin/false
Run Code Online (Sandbox Code Playgroud)

我正在努力解决的问题是Hudson中的这个错误:

Command "git fetch -t git@________.co.za:_______/_____________.git +refs/heads/*:refs/remotes/origin/*" returned status code 128: Host key verification failed.
Run Code Online (Sandbox Code Playgroud)

这是我的Dockerfile,它需要一个现有的hudson war文件和tar并且构建映像的配置,hudson运行正常,它只是因为用户tomcat7不存在的证书而无法访问git.

FROM debian:wheezy

# install java on image
RUN apt-get update
RUN apt-get install -y openjdk-7-jdk tomcat7

# install …
Run Code Online (Sandbox Code Playgroud)

git debian docker

60
推荐指数
5
解决办法
7万
查看次数

在docker镜像中部署WAR文件的正确方法

在docker容器中部署java项目的docker方式是什么?

我是否将战争复制到webapps:

FROM jetty:9.2.10
MAINTAINER Me "me@me.com"
ADD ./target/*.war /var/lib/jetty/webapps/ROOT.war
Run Code Online (Sandbox Code Playgroud)

或者我采取爆炸的战争档案:

FROM jetty:9.2.10
MAINTAINER Me "me@me.com"
ADD ./target/app-0.1.0.BUILD-SNAPSHOT /var/lib/jetty/webapps/ROOT
Run Code Online (Sandbox Code Playgroud)

通常情况下,如果它是一个普通的容器,就会部署密封的war文件,但是使用docker,这意味着每次进行一次小的更改时都会推送一个10-20MB的文件,而添加爆炸的战争只会推动差异 - .class文件已经改变.

部署爆炸战争而不是战争文件是否有任何缺点?

java jetty maven docker dockerfile

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

RabbitMQ RPC跨多个rabbitMQ实例

我有三个客户端,每个客户端都有自己的RabbitMQ实例,我有一个应用程序(让我们称之为appA),它有自己的RabbitMQ实例,三个客户端应用程序(app1,app2,app3)想要在appA上使用服务.

appA上的服务需要RPC通信,app1,app2和app3每个都有一个booking.request队列和一个booking.response队列.

在此输入图像描述

使用铲子插件,我可以将所有booking.request消息从app1-3转发到appA:

Shovel1 
virtualHost=appA, 
name=booking-request-shovel, 
sourceURI=amqp://userForApp1:password@app1-server/vhostForApp1
queue=booking.request
destinationURI=amqp://userForAppA:password@appA-server/vhostForAppA
queue=booking.request

setup another shovel to get booking requests from app2 and app3 to appA in the same way as above.
Run Code Online (Sandbox Code Playgroud)

现在appA将响应预订请求.响应队列,我需要在rabbitMQ-appA上的预订响应消息回到app1,app2或app3上的正确booking.response队列,但不是所有人 - 如何在rabbitMQ-appA上设置一个铲子/联合队列,它会将响应转发回正确的rabbitMQ(app1,app2,app3),这些兔子期望在他们自己的booking.response队列中得到响应?

所有这些应用程序都使用spring-amqp(如果相关的话)另外,我可以在Spring中设置一个rabbitMQ模板,它可以监听多个rabbitMQ队列,并从每个队列中消耗掉.

从文档中,这是典型的消费者的样子:

<rabbit:listener-container connection-factory="rabbitConnectionFactory">
    <rabbit:listener queues="some.queue" ref="somePojo" method="handle"/>
</rabbit:listener-container>
Run Code Online (Sandbox Code Playgroud)

是否可以指定多个连接工厂,即使连接工厂属于同一个RabbitMQ实例,也只是指定不同的vhost:

在此输入图像描述

更新:

基于Josh的回答,我有多个连接工厂:

 <rabbit:connection-factory
                id="connectionFactory1"
                port="${rabbit.port1}"
                virtual-host="${rabbit.virtual1}"
                host="${rabbit.host1}"
                username="${rabbit.username1}"
                password="${rabbit.password1}"
                connection-factory="nativeConnectionFactory" />

 <rabbit:connection-factory
                id="connectionFactory2"
                port="${rabbit.port2}"
                virtual-host="${rabbit.virtual2}"
                host="${rabbit.host2}"
                username="${rabbit.username2}"
                password="${rabbit.password2}"
                connection-factory="nativeConnectionFactory" />
Run Code Online (Sandbox Code Playgroud)

然后我将使用SimpleRoutingConnectionFactory来包装两个连接工厂:

<bean id="connectionFactory" class="org.springframework.amqp.rabbit.connection.SimpleRoutingConnectionFactory">
    <property name="targetConnectionFactories">
        <map>
            <entry key="#{connectionFactory1.virtualHost}" ref="connectionFactory1"/>
            <entry key="#{connectionFactory2.virtualHost}" ref="connectionFactory2"/>
        </map>
    </property>
</bean>
Run Code Online (Sandbox Code Playgroud)

现在,当我声明我的rabbitMQ模板时,我会将它指向SimpleRoutingConnectionFactory而不是单个连接工厂: …

rabbitmq federation spring-amqp rabbitmq-shovel

13
推荐指数
2
解决办法
3467
查看次数

在Kotlin中使用不同的值类型实现Hashmap

是否有可能在Kotlin中使用不同值类型的哈希映射?

我试过这个:

val template = "Hello {{world}} - {{count}} - {{tf}}"

val context = HashMap<String, Object>()
context.put("world", "John")
context.put("count", 1)
context.put("tf", true)
Run Code Online (Sandbox Code Playgroud)

...但是这给了我一个类型不匹配(apparantly "John",1true不是物)

在Java中,你可以通过创建类型的解决这个问题new String("John"),new Integer(1),Boolean.TRUE,我已经试过在科特林等价,但仍然得到类型不匹配错误.

context.put("tf", Boolean(true))
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

hashmap kotlin

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

使用Cloud PaaS会自动解决可扩展性问题吗?

我目前正在寻找一个Cloud PaaS,它允许我扩展一个应用程序来处理1个用户和1000万+用户之间的任何事情......我从来没有做过任何这么大的事情和我似乎无法做到的大问题得到明确的答案为是,如果你的发展,让我们说有一个关系型数据库和肥皂Web服务标准的应用程序,将这款应用规模部署在PaaS的解决方案或者你还需要建立与翻倒的应用程序时自动,冗余和所有这些事情?

假设我将一个Spring Hibernate应用程序部署到Amazon EC2并且我创建了安装了Tomcat的单个Ubuntu Server实例,这个应用程序是无限扩展还是需要更多Ubuntu实例?如果需要多个Ubuntu实例,亚马逊是否会负责在两个实例上运行应用程序,或者这是开发人员的责任吗?那么数据库存储呢,我可以在EC2上安装一个随着数据库的增长而扩展的数据库,或者我是否需要使用其中一个API而不是无限期扩展?

CloudFoundry允许你在本地构建和只是直接部署到各自的PaaS,但因为它是处于测试阶段,还有你可以使用和数据库的限制,如果我没有记错为128MB资源量的限制,所以这是一个不走现在.有人建议在Amazon EC2上安装CloudFoundry,它如何扩展以及如何处理数据库层?

GAE(谷歌应用引擎),这将允许我只是部署一个应用程序,而不必担心它如何扩展和实现冗余?你可以和不能在GAE上运行的东西似乎存在一些限制,而且他们的价格上涨最近让很多开发人员感到不安,与其他提供商相比,它真的那么昂贵吗?

所以基本上,它会扩展吗?需要做些什么才能使其扩展?

cloud google-app-engine amazon-ec2 amazon-simpledb cloud-foundry

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

jaxb2-maven-plugin只执行第一次执行

我正在尝试使用jaxb-maven插件使用JAXB将多个XSD转换为不同包中的POJO.我已将其设置为使用多个执行块,第一个执行块执行,然后我收到一条消息:在架构或绑定文件中未检测到任何更改

这是我的pom.xml的摘录:

...
<build>
    <pluginManagement>
        <plugin> 
            <groupId>org.codehaus.mojo</groupId> 
            <artifactId>jaxb2-maven-plugin</artifactId> 
            <version>1.5</version> 
        </plugin>
    </pluginManagement>
    <plugins>
    <!-- JAXB GENERATOR PLUGIN -->
    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>jaxb2-maven-plugin</artifactId>
        <version>1.5</version>
        <executions>                    
        <execution>
            <id>Application0</id>
            <phase>generate-sources</phase>
            <goals>
            <goal>xjc</goal>
            </goals>
            <configuration>
            <schemaDirectory>src/main/webapp/WEB-INF/xsd/version1</schemaDirectory>
            <packageName>za.co.mycee.application.model</packageName>
            <outputDirectory>${basedir}/src/main/java/</outputDirectory>
            <clearOutputDir>false</clearOutputDir>
            <source>1.5</source>
            <target>2.1</target>
            <arguments>-no-header</arguments>
            </configuration>
        </execution>                
        <execution>
            <id>Application1</id>
            <phase>generate-sources</phase>
            <goals>
            <goal>xjc</goal>
            </goals>
            <configuration>
            <schemaDirectory>src/main/webapp/WEB-INF/xsd/version1</schemaDirectory>
            <packageName>za.co.mycee.application.model.version1</packageName>
            <outputDirectory>${basedir}/src/main/java/</outputDirectory>
            <clearOutputDir>false</clearOutputDir>
            <source>1.5</source>
            <target>2.1</target>
            <arguments>-no-header</arguments>
            </configuration>
        </execution>
        <execution>
            <id>Application2</id>
            <phase>generate-sources</phase>
            <goals>
            <goal>xjc</goal>
            </goals>
            <configuration>
            <schemaDirectory>src/main/webapp/WEB-INF/xsd/version2</schemaDirectory>
            <packageName>za.co.mycee.application.model.version2</packageName>
            <outputDirectory>${basedir}/src/main/java/</outputDirectory>
            <clearOutputDir>false</clearOutputDir>
            <source>1.5</source>
            <target>2.1</target>
            <arguments>-no-header</arguments>
            </configuration>
        </execution>        
        </executions>
    </plugin>
    ...
</build>
....
Run Code Online (Sandbox Code Playgroud)

这是我收到的错误消息:

[INFO] --- jaxb2-maven-plugin:1.5:xjc (Application) …
Run Code Online (Sandbox Code Playgroud)

java jaxb2 maven

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

Dart:使用引用的所有元素将Map转换为JSON

我正在将Dart中的表单序列化为JSON,然后使用Jackson将其发布到Spring MVC后端以反序列化JSON.

在飞镖中,如果我打印出JSON,我会得到:

{firstName: piet, lastName: venter}
Run Code Online (Sandbox Code Playgroud)

杰克逊不喜欢这种格式的数据,它返回状态400和 The request sent by the client was syntactically incorrect.

如果我在所有字段周围加上引号,杰克逊接受数据并得到回复.

{"firstName": "piet", "lastName": "venter"}
Run Code Online (Sandbox Code Playgroud)

在dart中,我构建了一个Map<String, String> data = {};遍历所有表单字段的循环,然后执行data.putIfAbsent(input.name, () => input.value);

现在,当我打电话时data.toString(),我得到了不带引号的JSON,我猜测它是无效的JSON.

如果我import 'dart:convert' show JSON;尝试JSON.encode(data).toString();获得相同的未引用JSON.

手动附加双引号似乎有效:

data.putIfAbsent("\"" + input.name + "\"", () => "\"" + input.value + "\"");
Run Code Online (Sandbox Code Playgroud)

在Java方面,没有火箭科学:

@Controller
@RequestMapping("/seller")
@JsonIgnoreProperties(ignoreUnknown = true)
public class SellerController {

    @ResponseBody
    @RequestMapping(value = "/create", method = RequestMethod.POST, headers = {"Content-Type=application/json"})
    public Seller createSeller(@RequestBody …
Run Code Online (Sandbox Code Playgroud)

json spring-mvc jackson dart

12
推荐指数
2
解决办法
5124
查看次数

使用Maven JAXWS的多个WSDL配置

我需要在我的Maven JAXWS配置中包含多个WSDL,并且我需要为它们指定不同的输出目录,因为wsdlA中的某些方法名称与wsdlB中的方法名称冲突.我正在使用org.jvnet.jax-ws-commons,我需要绑定才能仅应用于wsdlA,而不是wsdlB.

这就是我现在所拥有的:

<build>
    <pluginManagement>
      <plugins>
        <plugin> 
          <groupId>org.jvnet.jax-ws-commons</groupId> 
          <artifactId>jaxws-maven-plugin</artifactId> 
          <version>2.1</version> 
          <executions>
            <execution> 
              <goals> 
                <goal>wsimport</goal> 
              </goals>
            </execution> 
          </executions>
          <configuration> 
            <!-- Configure Output -->
            <packageName>com.mycee.project.model</packageName> 
            <sourceDestDir>src/main/java</sourceDestDir>
            <!-- Configure WSDL Location -->
            <wsdlFiles>
              <wsdlFile>
                ${basedir}/src/jaxws/wsdl/wsdla.wsdl
              </wsdlFile>
              <!--
              <wsdlFile> 
                ${basedir}/src/jaxws/wsdl/wsdlb.wsdl
              </wsdlFile>
              -->   
            </wsdlFiles>
            <!-- Configure Binding Location -->
            <bindingDirectory>
              ${basedir}/src/jaxws/binding
            </bindingDirectory>
            <!-- Make Output Verbose -->
            <verbose>true</verbose>
          </configuration> 
        </plugin>         
      </plugins>            
    </pluginManagement>
  </build>
Run Code Online (Sandbox Code Playgroud)

更新:

<build>
    <pluginManagement>
      <plugins>
          <!-- WSDL GENERATOR PLUGIN -->
          <!-- mvn jaxws:wsimport    -->
          <plugin> 
              <groupId>org.jvnet.jax-ws-commons</groupId> 
              <artifactId>jaxws-maven-plugin</artifactId> 
              <version>2.3</version> 
              <executions>
                  <!-- WSDL A --> …
Run Code Online (Sandbox Code Playgroud)

jax-ws maven

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

在Google App Engine中存储旋转/翻转的图像

我正在尝试旋转/翻转已经位于Google云端存储中的图像.

这是blobkey:

BlobKey blobKey = new BlobKey(upload.getBlobKey());
Run Code Online (Sandbox Code Playgroud)

然后我检索图像并应用图像变换:

ImagesService imagesService = ImagesServiceFactory.getImagesService();
Image image = ImagesServiceFactory.makeImageFromBlob(blobKey);
Transform transform = ImagesServiceFactory.makeRotate(90);
Image newImage = imagesService.applyTransform(transform, image);
Run Code Online (Sandbox Code Playgroud)

我可以使用以下命令获取RAW图像数据:

newImage.getImageData()
Run Code Online (Sandbox Code Playgroud)

直接使用GCS,我可以将其写入云存储服务:

GcsFilename fileName = new GcsFilename("bucket-name", upload.getFileName());
GcsOutputChannel outputChannel = GcsServiceFactory.createGcsService().createOrReplace(fileName, GcsFileOptions.getDefaultInstance());
outputChannel.write(ByteBuffer.wrap(newImage.getImageData()));
outputChannel.close();
Run Code Online (Sandbox Code Playgroud)

在本地我可以看到旋转的图像位于appengine生成的文件夹中,如何获取新的服务URL或者objectName应该覆盖原始图像?objectName与上传时的原始文件名相同,是blobkey,......?

更新:

我在上传时存储GcsFilename:

BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
Map<String,List<FileInfo>> finfos = blobstoreService.getFileInfos(req);
String gcsFileName = finfos.get("uploadKey").get(0).getGsObjectName();
upload.setGcsFileName(gcsFileName);
upload.persist();
Run Code Online (Sandbox Code Playgroud)

GcsFileName看起来像这样(本地):

/ gs/bucket-name/fake-encoded_gs_key:YXVjdGlvbi1wb3J0YWwtdXBsb2Fkcy84SXp5VGpIUWlZSDY5X1Ytck5TbGtR-0f969f5b4f53a01479ff2d5eaf02fa1a(未编入索引)

然后在我的rotate方法中,我执行以下操作:

GcsFilename fileName = new GcsFilename( "bucket-name", upload.getGcsFileName());
GcsOutputChannel outputChannel = GcsServiceFactory.createGcsService().createOrReplace(fileName, GcsFileOptions.getDefaultInstance());
outputChannel.write(ByteBuffer.wrap(newImage.getImageData()));
outputChannel.close();

BlobstoreService bs = BlobstoreServiceFactory.getBlobstoreService(); …
Run Code Online (Sandbox Code Playgroud)

java google-app-engine blobstore google-cloud-storage

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

输入组中的多个按钮

我正在尝试实现一个左侧有多个按钮的输入组,现在只有一个按钮,如下图所示:

在此输入图像描述

问题是,只要每边有多个按钮,输入字段就会调整到最大宽度,并在较小的显示屏上踢出一个按钮:

在此输入图像描述

只有左侧的按钮和右侧的按钮,它在所有屏幕尺寸上都可以100%工作:

在此输入图像描述

Le Code:

    <div class="input-group br">
        <span class="input-group-btn">
            <div class="btn-group">
                <a href="#" class="btn btn-primary clear-search">
                    <span class="glyphicon glyphicon-refresh"></span>
                </a>
                <a href="#" class="btn btn-primary qr-code">
                    <span class="glyphicon glyphicon-qrcode"></span>
                </a>
            </div>
        </span>
        <input class="form-control search" type="search" name="search" placeholder="Search">
        <span class="input-group-btn">
            <div class="btn-group dropup">
                <button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    <span class="glyphicon glyphicon-search"></span>
                    Search
                    <span class="caret"></span>
                </button>
                <ul class="dropdown-menu dropdown-menu-right">
                    <li><a class="buyer-identifier" href="#">Buyer Number</a></li>
                    ...
                    <li class="divider"></li>
                    <li><a class="clear-search" href="#">Clear Search</a></li>
                </ul>
            </div>
        </span>
    </div>
Run Code Online (Sandbox Code Playgroud)

小提琴演示

有关如何使第一张图像适用于所有屏幕尺寸的任何想法?

html css twitter-bootstrap twitter-bootstrap-3

8
推荐指数
2
解决办法
8002
查看次数