小编Tom*_*rko的帖子

将Yaml中的列表映射到Spring Boot中的对象列表

在我的Spring Boot应用程序中,我有application.yaml配置文件,其中包含以下内容.我想将它作为配置对象注入通道配置列表:

available-payment-channels-list:
  xyz: "123"
  channelConfigurations:
    -
      name: "Company X"
      companyBankAccount: "1000200030004000"
    -
      name: "Company Y"
      companyBankAccount: "1000200030004000"
Run Code Online (Sandbox Code Playgroud)

和@Configuration对象我想填充PaymentConfiguration对象列表:

    @ConfigurationProperties(prefix = "available-payment-channels-list")
    @Configuration
    @RefreshScope
    public class AvailableChannelsConfiguration {

        private String xyz;

        private List<ChannelConfiguration> channelConfigurations;

        public AvailableChannelsConfiguration(String xyz, List<ChannelConfiguration> channelConfigurations) {
            this.xyz = xyz;
            this.channelConfigurations = channelConfigurations;
        }

        public AvailableChannelsConfiguration() {

        }

        // getters, setters


        @ConfigurationProperties(prefix = "available-payment-channels-list.channelConfigurations")
        @Configuration
        public static class ChannelConfiguration {
            private String name;
            private String companyBankAccount;

            public ChannelConfiguration(String name, String companyBankAccount) {
                this.name = name;
                this.companyBankAccount = …
Run Code Online (Sandbox Code Playgroud)

java spring yaml spring-boot

47
推荐指数
5
解决办法
8万
查看次数

在angularjs中使用来自rest服务的JSON对象

我有一个休息服务返回JSON一个数字

{"uptime":"44"}
Run Code Online (Sandbox Code Playgroud)

在网址下提供:

http://localhost/uptime
Run Code Online (Sandbox Code Playgroud)

我想使用angularJS在页面上显示此值.

我写了一个资源来从这个rest url获取数据:

angular.module('utilService', ['ngResource']).
factory('UtilService', function($resource) {
    var UtilService = $resource('/uptime', { },
        {
            'get' : { method: 'GET', params: { format: '.json' } , isArray : false }
        }
    )


    UtilService.loadUptime = function(cb) {
        return UtilService.get();
    }

    return UtilService;
});
Run Code Online (Sandbox Code Playgroud)

但是当我在Controller中使用它时:

angular.module('log', ['logService', 'utilService']);


function UptimeCtrl($scope, UtilService) {
    var time = UtilService.loadUptime();
    $scope.uptime = time;
}
Run Code Online (Sandbox Code Playgroud)

我在页面上看到的只是{"正常运行时间":"44"}

我想我需要将接收到的对象提取/转换为JSON并获得它'uptime'属性.但是我尝试了JSON.parse,time.uptime,time ['uptime']而没有成功.

我要么做一些完全错误的事情,要么在这里遗漏一些基本问题.

javascript rest json angularjs

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

Selenium没有看到AngularJS页面元素

我在编写Selenium测试以检查我的应用程序时遇到问题.我想测试的是当用户输入正确的登录名/密码时,会显示正确的页面并且用户已登录.

主要问题是我的登录表单是作为AngularJS指令生成的(我有两个不同的登录页面,这个指令在两个地方都被重用),而Selenium似乎无法看到这个指令生成的标记中的元素.最重要的是,在我用指令生成的常规标记替换之前,测试正在传递此页面.

所以看起来Selenium似乎无法看到由指令生成的html元素.

有什么建议我如何克服这个问题?除了当然还原这个变化引入指令:)

selenium angularjs angularjs-directive

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

Wicket @SpringBean和Spring @Autowired通过构造函数注入

我有一个Wicket面板,我想在其中使用@SpringBean注入bean

public class SomePanel extends Panel {

  @SpringBean
  private BlogSummaryMailGenerator blogSummaryMailGenerator;

}
Run Code Online (Sandbox Code Playgroud)

但是这个BlogSummaryMailGenerator通过如下定义的构造函数注入:

@Component
public class BlogSummaryMailGenerator {

  private BlogRepository blogRepository;
  private BlogPostRepository blogPostRepository;

  @Autowired
  public BlogSummaryMailGenerator(BlogRepository blogRepository,
                                BlogPostRepository blogPostRepository) {
    this.blogRepository = blogRepository;
    this.blogPostRepository = blogPostRepository;
  }
}
Run Code Online (Sandbox Code Playgroud)

当SomePanel被实例化时,我得到一个例外

Caused by: java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given
at net.sf.cglib.proxy.Enhancer.emitConstructors(Enhancer.java:721) ~[cglib-3.1.jar:na]
at net.sf.cglib.proxy.Enhancer.generateClass(Enhancer.java:499) ~[cglib-3.1.jar:na]
at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25) ~[cglib-3.1.jar:na]
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216) ~[cglib-3.1.jar:na]
at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377) ~[cglib-3.1.jar:na]
at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:285) ~[cglib-3.1.jar:na]
at org.apache.wicket.proxy.LazyInitProxyFactory.createProxy(LazyInitProxyFactory.java:191) ~[wicket-ioc-7.2.0.jar:7.2.0]
Run Code Online (Sandbox Code Playgroud)

将空的no-args构造函数添加到BlogSummaryMailGenerator可以解决此问题,但仅添加此类代码以使注入工作是错误的,我想避免它.

有关如何通过构造函数使用注入使@SpringBean与bean一起工​​作的任何建议吗?

java spring wicket dependency-injection

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

在Windows10上的Postgresql中创建utf-8数据库

我正在尝试在Windows 10上创建utf-8数据库:

createdb.exe -h localhost -p 53131 -U user -E UTF8 -T template0 -l en_US.utf-8 test777
Run Code Online (Sandbox Code Playgroud)

但是响应是:

createdb: database creation failed: ERROR:  invalid locale name: "en_US.utf-8"
Run Code Online (Sandbox Code Playgroud)

有什么线索吗?

postgresql

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

deploymentURL没有注入到Arquillian Drone的集成测试中

我正在尝试在我们的项目中使用Arquillian Drone引入集成测试.我做了一些小的演示应用程序,读了一些东西,最后尝试为相对简单的网页编写一个简单的集成测试.

我想我已经解决了所有必需的依赖项,并且我能够在Intellij Idea中运行我的测试类.但是当我运行它时,我得到一个例外说:

java.lang.RuntimeException:找不到字段java.net.URL com.example.BEViewUIWithDrone.deploymentURL(...)的值

引起:

java.lang.RuntimeException:类型类java.net.URL的Provider在org.jboss.arquillian.test.impl返回一个空值:org.jboss.arquillian.container.test.impl.enricher.resource.URLResourceProvider@6e73a35c. richher.resource.ArquillianResourceTestEnricher.lookup(ArquillianResourceTestEnricher.java:115)at org.jboss.arquillian.test.impl.enricher.resource.ArquillianResourceTestEnricher.enrich(ArquillianResourceTestEnricher.java:57)"(完整堆栈跟踪下)

我的考试班:

public class BEViewUIWithDrone extends Arquillian {

    private static final String WEBAPP_SRC = "project/src/main/webapp";

    @Drone
    private DefaultSelenium selenium;

    @ArquillianResource
    URL deploymentURL;


    @Deployment(testable = false)
    public static WebArchive createDeployment() {

        MavenDependencyResolver resolver = DependencyResolvers
                .use(MavenDependencyResolver.class)
                .loadDependenciesFromPom("pom.xml");

        File[] jbossLogging = resolver.artifact("org.jboss.logging:jboss-logging:3.0.0.GA").resolveAsFiles();
        File[] solder = resolver.artifact("org.jboss.seam.solder:seam-solder:3.0.0.Final").resolveAsFiles();

        return ShrinkWrap.create(WebArchive.class, "be-view.war")
                .addAsLibraries(jbossLogging)
                .addAsLibraries(solder)
                .addClasses(BorrowingEntityService.class)
                .addClasses(BorrowingEntityViewService.class)
                .addClasses(ViewingService.class)
                .addClasses(QueryLimit.class)
                .addClasses(CustomerService.class)
                .addClasses(MockProducer.class)
                .addAsWebResource(new File(WEBAPP_SRC, "view/be/borrowingEntityView.xhtml"))
                .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
                .addAsWebInfResource(
                        new StringAsset("<faces-config version=\"2.0\"/>"),
                        "faces-config.xml");
    }

    @Test
    public void simpleTest() { …
Run Code Online (Sandbox Code Playgroud)

java testing jboss-weld jboss-arquillian

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

我如何简化此Scala选项的使用

我有以下代码获取参数,如果它是有效的ObjectId,则将其转换为Option [ObjectId],否则返回None.

我在想它如何简化,但没有找到更好的东西.

注意:params.get("desiredImage")是Option [String]

val imageId: Option[ObjectId] = params.get("imageId") match {
  case None => None
  case Some(x) => {
    if (ObjectId.isValid(x)) {
      Some(new ObjectId(x))
    } else {
      None
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

scala

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