小编abi*_*rai的帖子

Signurl 命令需要 Google 存储中 gsutil 中的 pyopenssl 库来创建签名 URL

我正在尝试使用 gsutil 创建签名 URL。以下是命令 $ gsutil signurl -d 10m path/to/privatekey.p12 gs://bucket/foo

网站https://developers.google.com/storage/docs/accesscontrol中提到

我还使用我的存储桶名称和对象发出了相同的命令,如下所示

gsutil signurl -d 10m C:\Users\Desktop\javascript\service\4e263da.p12 gs://code-sample/File1

但我收到以下错误

“signurl 命令需要 pyopenssl 库,请尝试 pip install pyopenssl 或 easy_install pyopenssl”

.所以,我从这里安装了 Windows 的 PyOpenSSL

https://pypi.python.org/pypi/pyOpenSSL/0.13。我的 python 版本是 2.6。在运行命令时我仍然遇到相同的错误。所以我的问题是为什么在 gsutil 中安装 pyopenssl 后仍然无法识别命令signurl

pyopenssl python-2.6 google-cloud-storage

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

如何在java中解压非UTF8格式的文件

我有一个文件,例如 test.zip。如果我使用像 winrar 这样的 ZIP 工具,则很容易解压(将 test.zip 解压缩为 test.csv)。但 test.csv 不是 UTF8 格式。我的问题是,当我使用java解压它时,它无法读取这个文件。

ZipFile zf = new ZipFile("C:/test.zip");
Run Code Online (Sandbox Code Playgroud)

抛出的异常表明打开该文件时发生错误。

在java上http://java.sun.com/developer/technicalArticles/Programming/compression/没有写任何关于数据格式化的内容。也许整个 API 是专门为 UTF8 格式的数据设计的。那么,如果我必须解压除UTF8格式之外的数据,该如何解压呢?特别是日文和中文字符占用的空间较大(UTF8 除外)。我还在http://truezip.java.net/6/tutorial.html找到了一个 API ,其中提到了这个问题。但是,我没有找到解决问题的方法。有什么简单的方法可以解决这个问题吗?尤其是从JAVA规范请求传递过来的API。

java

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

不是 JAX-WS 中的有效服务异常

我正在参考http://www.mkyong.com/webservices/jax-ws/jax-ws-hello-world-example/

这是我的 HelloWorldClient

package WebService;


import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;



public class HelloWorldClient{

    public static void main(String[] args) throws Exception {

    URL url = new URL("http://localhost:8099/dummy1/dummy2?wsdl");

        //1st argument service URI, refer to wsdl document above
    //2nd argument is service name, refer to wsdl document above
        QName qname = new QName("http://localhost:8099/dummy1/dummy2?wsdl", "HelloWorldImplService");


        Service service = Service.create(url, qname);

        HelloWorld hello = service.getPort(HelloWorld.class);

        System.out.println(hello.getHelloWorldAsString("mkyong"));

    }

}
Run Code Online (Sandbox Code Playgroud)

运行这个类时,我从下面的代码行收到错误

Service service = Service.create(url, qname);
Run Code Online (Sandbox Code Playgroud)

错误是

Exception in thread "main" javax.xml.ws.WebServiceException: {http://localhost:8099/dummy1/dummy2?wsdl}HelloWorldImplService is …
Run Code Online (Sandbox Code Playgroud)

java soap jax-ws

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

Spring事务管理器和多线程

我正在使用Callable接口在serviceImpl中编写多线程程序.我正在使用spring事务管理器.当在DB中执行更新操作时,它会成功执行.但更新的数据不会反映在DB中.但是当我在没有多线程的情况下运行程序时,它会在DB中更新.

这是我的配置

<tx:advice id="txAdvice" transaction-manager="txManager">
        <tx:attributes>
            <tx:method name="*" />
            <tx:method name="find*" propagation="NOT_SUPPORTED" />
            <tx:method name="get*" propagation="NOT_SUPPORTED" />
        </tx:attributes>
    </tx:advice>
    <aop:config>
        <aop:pointcut id="serviceOperation" expression="execution(* *..*ServiceImpl.*(..))" />
        <aop:advisor advice-ref="txAdvice" pointcut-ref="serviceOperation" />
    </aop:config>
    <bean id="txManager"
        class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource" />
    </bean>
Run Code Online (Sandbox Code Playgroud)

我可以转向另一种方法来处理事务管理器.我想知道这种方法是否支持多线程.所以我的问题是 Spring spring事务管理器是否支持多线程(我的意思是仅通过声明注释或XML)为什么在我的情况下更新数据不会反映在DB中? 什么是最好的替代方法?

java spring spring-transactions

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

在 Spring Cloud Gateway 中将配置从 Ribbon 更改为 Spring Cloud Load Balancer

我有以下带有功能区的 Spring Cloud Gateway 配置

server:
  port: 8080

spring:
  cloud:
    gateway:
      routes:
        - id: UserModule
          uri: lb://load-balanced-service-user
          predicates:
            - Path=/api/user/**
ribbon:
  eureka:
    enabled: false
Load-balanced-service-user:
  ribbon:
    listOfServers: localhost:9999,localhost:8888
Run Code Online (Sandbox Code Playgroud)

现在我想删除 Ribbon 并替换为 Spring Cloud 负载均衡器。

我添加了

 <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-loadbalancer</artifactId>
        </dependency>
Run Code Online (Sandbox Code Playgroud)

现在我需要在 application.yaml 文件中添加哪些其他配置才能切换到 Spring Cloud 负载均衡器?我想在 .yaml 文件上添加配置。我不想用 .yaml 文件中配置的功能区破坏旧结构。

spring-boot spring-cloud-netflix spring-cloud-gateway spring-cloud-loadbalancer

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

Ehcache-spring-annotations @Cacheable没有捕获String对象作为参数的方法

我正在使用ehcache-spring-annotations-1.2.0.jar. 这是我的cache.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:oxm="http://www.springframework.org/schema/oxm"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:ehcache="http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
        http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
        http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring/ehcache-spring-1.1.xsd">

    <ehcache:annotation-driven />



    <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"/>



</beans>
Run Code Online (Sandbox Code Playgroud)

这是我的ehcache.xml

<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd">

        <cache name="messageCache" eternal="false"
        maxElementsInMemory="5" overflowToDisk="false" diskPersistent="false"
        timeToIdleSeconds="1000" timeToLiveSeconds="3000"
        memoryStoreEvictionPolicy="LRU" />
Run Code Online (Sandbox Code Playgroud)

这是我的主要代码

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.googlecode.ehcache.annotations.Cacheable;

public class EcacheSpringtest {
    private static ApplicationContext cachecontext = new ClassPathXmlApplicationContext("cache.xml");

    @Cacheable(cacheName = "messageCache")
    String getName(String name) {

        System.out.println(name+ " "+"has not been found in the cache …
Run Code Online (Sandbox Code Playgroud)

java spring ehcache

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

如何在 Spring Boot 中使用 keycloak-admin-client 使用电子邮件启用 2FA

我的要求是在 Keycloak 中使用电子邮件启用 2FA。

启用后,如果用户尝试通过电子邮件和密码登录,用户成功通过身份验证后,基于时间的令牌将发送到电子邮件。

用户将通过自定义 UI 执行此操作,即在我们的产品中,我们有 UI 为用户启用/禁用 2FA。

我们正在使用 Keycloak 并且我们希望使用 Keycloak API 来实现这一点。

我正在使用 keycloak-admin-client 与 Keycloak API 进行交互,但我没有找到足够的资源来使用 keycloak-admin-client 实现此目的。

我正在寻找一种使用 keycloak-admin-client 为用户启用 2FA 的方法。

任何帮助将不胜感激。

谢谢

keycloak keycloak-rest-api keycloak-admin-client keycloak-spring-boot-starter

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