小编Luc*_*cas的帖子

是否可以在打字稿中输出*作为foo

我可以:

import * as foo from './foo'
Run Code Online (Sandbox Code Playgroud)

但似乎无法出口相同:

export * as foo from './foo'
Run Code Online (Sandbox Code Playgroud)

这似乎也不起作用......:

import * as fooImport from './foo';
export const foo = fooImport;
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

---更新---

你想要实现什么目标?

基本上,我正在ngrx/store为我的应用程序实现后端.我想组织我的代码:

app/core/
  index.ts
  viewer/
    index.ts
    viewer-actions.ts
    viewer-reducer.ts
  view-data/
    index.ts
    view-data-actions.ts
    view-data-reducer.ts
Run Code Online (Sandbox Code Playgroud)

我想用我的index.ts文件链接每个子集的所有导出(常见范例).

但是,我想保留命名空间.我的每个xxx-reducer.tsxxx-actions.ts文件具有相同的名称(出口reducer,ActionTypes,Actions,...),所以正常的链接会导致名称冲突.我所试图做的是让所有从出口xxx-actionsxxx-reducer再出口xxx.这将允许我:

import { viewer, viewerData } from './core';

...
    private viewer: Observable<viewer.Viewer>;
    private viewData: Observable<viewData.ViewData>; …
Run Code Online (Sandbox Code Playgroud)

module export typescript

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

maven-surefire-plugin包含/排除优先级

当使用maven-surefire-plugin并且包含和排除时,它们处理的顺序是什么?此外,如果您有3组测试,第一组是基本集,第二组和第三组是特殊情况,您是否可以使用配置文件进一步包含/排除?如何合并配置文件包含/排除设置?例如,我想做这样的事情:

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.12.2</version>
        <configuration>
          <excludes>
            <exclude>/org/mycompany/dataset/test/ExtractProd*.java</exclude> <!-- requires special network connectivity -->
            <exclude>/org/mycompany/dataset/test/LargeDataset*.java</exclude> <!-- requires lengthy processing -->
          </excludes>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>connectedToProdNetwork</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <includes>
                <include>/org/mycompany/dataset/test/ExtractProd*.java</include>
              </includes>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>runForAsLongAsYouNeed</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <includes>
                <include>/org/mycompany/dataset/test/LargeDataset*.java</include>
              </includes>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
Run Code Online (Sandbox Code Playgroud)

然后能够像这样运行:

mvn package -P connectedToProdNetwork
Run Code Online (Sandbox Code Playgroud)

要么

mvn package -P runForAsLongAsYouNeed
Run Code Online (Sandbox Code Playgroud)

要么

mvn package -P connectedToProdNetwork,runForAsLongAsYouNeed
Run Code Online (Sandbox Code Playgroud)

----更新-----

使用mvn help:effective-pom …

java pom.xml maven-3 maven maven-surefire-plugin

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

杰克逊JSON + Java泛型

我正在尝试List<Bill使用Jackson json库将以下JSON反序列化/映射到> java对象.(这个json是由杰克逊生成的,Iam为了简洁省略了那篇文章)

{"bills":[{"amount":"13","billId":"billid3"}]}
Run Code Online (Sandbox Code Playgroud)

这是我的转换方法:

private static void convert(){
   String jsonBill =  "{\"bills\":[{\"amount\":\"13\",\"billId\":\"billid3\"}]}";

   ObjectMapper mapper = new ObjectMapper();
   List<Bill> bills = null;
   try {
       bills = mapper.readValue(jsonBill, new TypeReference<List<Bill>>() { });
   } catch (Exception e) {
       e.printStackTrace();
   }
   System.out.println("bills = " + bills.size());
}
Run Code Online (Sandbox Code Playgroud)

该法案实体如下:

@JsonTypeInfo(use=JsonTypeInfo.Id.CLASS)
public class Bill { 
   private String amount;
   private String billId;

   public String getBillId() {
       return billId;
   }
   public void setBillId(String billId) {
       this.billId = billId;
   }
   public String getAmount() { …
Run Code Online (Sandbox Code Playgroud)

java generics json jackson deserialization

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

Spring boot 2.0.0.M1 NoSuchMethodError:org.springframework.boot.builder.SpringApplicationBuilder.<init>

我在https://start.spring.io/上使用了启动页面生成了一个包含许多模块的项目当我尝试运行测试时,我得到了很多日志信息,但这些行似乎是关键

10:29:33.198 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [Inlined Test Properties] PropertySource with highest search precedence
10:29:33.364 [main] DEBUG org.springframework.boot.context.logging.ClasspathLoggingApplicationListener - Application failed to start with classpath: [file:/C:/privilege/target/surefire/surefirebooter1615922581175854972.jar]
10:29:33.369 [main] ERROR org.springframework.boot.SpringApplication - Application startup failed
java.lang.NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBuilder.<init>([Ljava/lang/Object;)V
    at  org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:157)
    at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:98)
    at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:64)
Run Code Online (Sandbox Code Playgroud)

我选择的模块是:

  • 安全
  • AOP
  • 网球衣(JAX-RS)
  • 休息库
  • DevTools
  • 高速缓存
  • 会议
  • 移动
  • 休息
  • 文件
  • Thymeleaf
  • MongoDB的
  • Zuul
  • Zookeeper Discovery
  • Solr的
  • 的OAuth2
  • 龙目岛
  • 重试

我不得不为生成的pom制作一些mod,但我认为我有一套合理的版本.从STS生成的"有效pom"中,获取以下属性:

<spring-batch.version>4.0.0.M2</spring-batch.version>
<undertow.version>1.4.14.Final</undertow.version>
<httpclient.version>4.5.3</httpclient.version>
<maven-surefire-plugin.version>2.18.1</maven-surefire-plugin.version>
<webjars-locator.version>0.32-1</webjars-locator.version>
<spring-ldap.version>2.3.1.RELEASE</spring-ldap.version>
<spring-security-oauth.version>2.1.0.RELEASE</spring-security-oauth.version>
<hibernate.version>5.2.10.Final</hibernate.version>
<groovy.version>2.4.11</groovy.version>
<rxjava2.version>2.1.0</rxjava2.version>
<byte-buddy.version>1.6.14</byte-buddy.version>
<spring-social-linkedin.version>2.0.0.M2</spring-social-linkedin.version>
<jmustache.version>1.13</jmustache.version> …
Run Code Online (Sandbox Code Playgroud)

spring-boot

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

连接池或数据源?我应该把它放在哪个JNDI?

在JNDI级别或Webapp级别连接池更有意义吗?例如,我可以简单地在javax.sql.DataSource创建:

<Context antiJARLocking="true">
  <Resource name="jdbc/myDataSource" 
    auth="Container"
    type="javax.sql.DataSource" 
    driverClassName="com.mysql.jdbc.Driver"
    url="jdbc:mysql://localhost/myDataSource" user="user" password="password" />
</Context>
Run Code Online (Sandbox Code Playgroud)

然后在Spring中配置池:

<bean id="myDataSource" class="com.mchange.v2.c3p0.DataSources"
  factory-method="pooledDataSource">
  <constructor-arg>
    <jee:jndi-lookup jndi-name="java:comp/env/jdbc/myDataSource" />
  </constructor-arg>
</bean>
Run Code Online (Sandbox Code Playgroud)

或者,我可以直接在JNDI本身配置池:

<Resource name="jdbc/myDataSource" 
  auth="Container"
  factory="org.apache.naming.factory.BeanFactory"
  type="com.mchange.v2.c3p0.ComboPooledDataSource" 
  driverClassName="com.mysql.jdbc.Driver"
  jdbcUrl="jdbc:mysql://localhost/myDataSource" 
  user="user" password="password"
  minPoolSize="3" 
  maxPoolSize="15" 
  maxIdleTime="5000"
  idleConnectionTestPeriod="300" 
  acquireIncrement="3" />
Run Code Online (Sandbox Code Playgroud)

离开这个春天:

<jee:jndi-lookup id="myDataSource" jndi-name="java:comp/env/jdbc/myDataSource" />
Run Code Online (Sandbox Code Playgroud)

在这两种情况下,myDataSource spring bean都是一个c3p0连接池数据源,但哪一个更好?我认为在JNDI中使用池是最有意义的,但缺点是你必须将c3p0 lib推送到servlet容器级别,这可能会导致与现有servlet冲突,如果它们当前使用不同的版本.但是,将它放在JNDI中意味着您的应用程序根本不必担心池化.你们都在想什么?

java tomcat jndi datasource connection-pooling

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

Java泛型的泛型

我有一个表示文本片段的泛型类.该文本片段可以具有许多不同模式中的任何一种(不同类型的突出显示).这些模式由Enum表示.对于每个项目,枚举可能不同,但它必须实现一个接口,该接口提供了一种方法来组合其中两个(可以突出显示和加粗).所以我有一个界面:

public interface TextFragmentMode<E extends Enum<E>> {
    /**
     * Will combine the supplied mode with the current mode and return the
     * result.
     * 
     * @param mode The mode to combine with.
     * @return The combined mode.
     */
    public E combine( E mode );
}
Run Code Online (Sandbox Code Playgroud)

然后我的TextFragment是一个文本字符串和一个模式的容器.但是当我尝试宣布这个课时:

public class TextFragment<E extends TextFragmentMode<E extends Enum<E>>> {
    StringBuilder text;
    E mode;
    ...
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

令牌"extends"的语法错误,预期

根据eclipse语法突出显示,其中指的是

E extends Enum<E>
Run Code Online (Sandbox Code Playgroud)

部分代码.有谁知道我做错了什么?我一定错过了关于泛型的东西......

---------------------编辑-------------------

我终于花时间阅读Josh Bloch撰写的Effective Java(第二版),结果发现他已经过了这个用例,如第34项:使用接口模拟可扩展的枚举.尽管我想说伟大的思想一样......但这样做太过于pres!

java generics enums

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

使用Selenium2和FirefoxDriver关闭Liferay弹出窗口(在新的浏览器窗口中)?

我试图使用Selenium 2在Liferay门户服务器上自动化一些测试用例.许多Liferay操作会弹出新的浏览器窗口(如用户模拟).这是一个示例链接(注意target="_blank"):

<a title="(Opens New Window)" target="_blank" id="_125_xafr" 
    href="/web/guest?doAsUserId=xBRUWI85MvM%3D" class="taglib-icon aui-focus" 
    tabindex="0" role="menuitem"> 
  <img alt="" src="/html/themes/control_panel/images/common/impersonate_user.png" class="icon"> 
  Impersonate User 
  <span class="opens-new-window-accessible">(Opens New Window)</span>
</a>
Run Code Online (Sandbox Code Playgroud)

切换到弹出窗口上下文非常简单:

String currentWindowHandle = driver.getWindowHandle();
if ( log.isDebugEnabled() ) log.debug( "currentWindowHandle='" + currentWindowHandle + "'" );
for ( String windowHandle : driver.getWindowHandles() ) {
    if ( ! windowHandle.equals( currentWindowHandle ) ) {
        boolean impersonationSuccess = false;
        if ( log.isDebugEnabled() ) log.debug( "checking '" + windowHandle + "' impersonation alert notice" );
        driver.switchTo().window( windowHandle ); …
Run Code Online (Sandbox Code Playgroud)

debugging firefox popup liferay selenium-webdriver

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

你能声明一个允许打字稿中未知属性的对象文字类型吗?

基本上我想确保一个对象参数包含所有必需的属性,但可以包含它想要的任何其他属性.例如:

function foo(bar: { baz: number }) : number {
    return bar.baz;
}

foo({ baz: 1, other: 2 });
Run Code Online (Sandbox Code Playgroud)

但这会导致:

Object literal may only specify known properties, and 'other' does not exist in type '{ baz: number; }'.
Run Code Online (Sandbox Code Playgroud)

generics object-literal typescript typescript2.0

9
推荐指数
4
解决办法
3720
查看次数

如何验证primefaces树<p:tree>

看来,primefaces <p:tree>不是一个EditableValueHolder的,即使它提供了使树选择的能力.对我来说,这似乎是的非常清晰EditableValueHolder,因为它既持有价值(即选择节点列表)可编辑(你可以改变选择).在使树可选时,它基本上将其转换为selectOneXxx/selectManyXxx.这是我使用这个小部件的时尚.但是,不是EditableValueHolder,我无法直接附加验证器.我可以使用a添加对表单提交操作的验证,actionListener但是它超出了相应的生命周期阶段,并且更难以在UITree组件中检查属性,例如i18n消息验证失败.以前有人处理过这个吗?你是做什么?

----------编辑----------

我发现在primefaces bug跟踪器中发布的一个问题似乎已经解决了:

http://code.google.com/p/primefaces/issues/detail?id=4137

一个论坛帖子:

http://forum.primefaces.org/viewtopic.php?f=3&t=22340

----------编辑----------

这是我提出的解决方案.一些jQuery非常多毛,因为它使用服务器端el来生成客户端javascript.但在大多数情况下它都有效.只需要弄清楚为什么一个空数组会跳过验证...但那是另一个故事.

<h:panelGroup id="pnpCois" styleClass="pnp-input-group pnp-cois">
  <h:outputLabel for="inputCois"
    value="#{i18n['communities-of-interest']}" />
  <p:tree id="inputCois"
    value="#{subscriptions.selected.coiTreeRootNode}" var="node"
    selectionMode="checkbox"
    selection="#{subscriptions.selected.selectedCoiNodes}">
    <p:ajax event="select" process="@this :#{component.clientId}_validator" update="@this"
      onstart="$('##{component.clientId}_validator'.replace(':','\\:')).val($('##{component.clientId}_selection'.replace(':','\\:')).val());" />
    <p:ajax event="unselect" process="@this :#{component.clientId}_validator" update="@this"
      onstart="$('##{component.clientId}_validator'.replace(':','\\:')).val($('##{component.clientId}_selection'.replace(':','\\:')).val());" />
    <p:treeNode>
      <h:outputText value="#{node}" />
    </p:treeNode>
  </p:tree>
  <h:inputHidden id="inputCois_validator">
    <f:converter converterId="asias.stringCsvToArray" /> 
    <f:validator validatorId="asias.atLeastOneSelected" />
    <f:attribute name="atLeastOneSelectedMessage"
      value="#{i18n['at-least-one-coi-must-be-selected']}" />
  </h:inputHidden>
</h:panelGroup>
Run Code Online (Sandbox Code Playgroud)

----------编辑----------

在与BalusC一起完成一些建议后,我想我会放弃<p:tree>并找到另一种方式...... :(

validation treeview primefaces jsf-2

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

有谁知道powershell证书提供程序路径如何映射到certmgr.msc文件夹?

当使用powershell来调查证书提供程序时,我注意到所有路径看起来都certmgr中的文件夹结构相似但不相同.看起来很清楚:

Certs:\LocalMachine ~= Certificates (Local Computer)
Certs:\CurrentUser ~= Certificates - Current User
Run Code Online (Sandbox Code Playgroud)

我也猜测:

Root ~= Trusted Root Certification Authority
My ~= Personal
WebHosting ~= WebHosting
...
Run Code Online (Sandbox Code Playgroud)

但我一直无法找到任何官方参考(甚至是明智的解释)给我温暖的模糊我正在寻找......

我的目的是在本地测试https WCF服务(服务器端和客户端端).我可以使用New-SelfSignedCertificate轻松生成服务器所需的自签名证书.但是,如果我尝试将我的客户端(也是.NET)指向该服务,则该服务无法连接,因为该服务提供了不受信任的证书.

我找到了各种过时的引用(比如这个),展示了如何使用makecert(现已弃用)和certmgr的组合来生成证书颁发机构,然后使用它来为我的https服务签署证书,然后安装证书颁发机构证书进入受信任的根证书颁发机构容器以使一切正常运行.虽然这种方法可能会起作用,但它肯定不是开发人员/自动化友好的.

也就是说,我能够使用powershell来做到这一点:

$my_cert_store_location = "Cert:\LocalMachine\My"
$root_cert_store_location = "Cert:\LocalMachine\Root"
$root_friendly_name = "Test Root Authority"
$root_cert_subject = "CN=$($root_friendly_name)"
# The ip and port you want to reserve for your app
$ipport = "127.0.0.11:8734"
# …
Run Code Online (Sandbox Code Playgroud)

windows powershell certificate-authority self-signed ssl-certificate

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