小编Pan*_*kaj的帖子

如果在pluginManagement下定义了插件,则maven目标无法正确执行

我有maven-jaxb2-plugin.我生成jaxb对象并在其他类项目中引用它.我已经在pluginManagement标记下放了jaxb插件和编译器插件.Maven正在执行编译阶段而不是生成阶段,就好像我删除了pluginManagement标记一样,它工作正常,首先生成阶段执行并生成所有jaxb对象,然后执行编译阶段.由于pluginManagement标记,我的项目无法编译.pluginManagement标记是否仅用于定义父pom中的所有插件,以便子pom可以引用这些插件?我的项目不是一个多模块项目.

   <pluginManagement>       
      <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
                <encoding>UTF-8</encoding>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <schemaDirectory>${basedir}/src/main/resources/schema</schemaDirectory>
                <generatePackage>com.common.dto</generatePackage>
                <schemaIncludes>
                    <include>*.xsd</include>
                </schemaIncludes>
                <removeOldOutput>false</removeOldOutput>
                <strict>false</strict>
                <verbose>true</verbose>
                <forceRegenerate>true</forceRegenerate>
                <extension>true</extension>
            </configuration>
        </plugin>
    </plugins>
 </pluginManagement>
Run Code Online (Sandbox Code Playgroud)

maven-plugin maven

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

SocketTimeoutException:读取超时 httpclient

我有一个 REST 服务,每天处理大约 2000 万个请求。我收到以下异常。此问题是间歇性的,我无法将此问题与请求量联系起来。我在周末也遇到了这个例外,当时成交量非常低。我确实通过检查确保没有石碑连接setStaleConnectionCheckEnabled。我在用着httpclient 4.3.4

更新:进一步分析后的一些更多细节 -

从日志中,我可以看到服务在 300 毫秒内响应了大部分请求,但是客户端需要时间连接到服务本身,并且在收到响应时,它已经超过了 6 秒的阈值并进入了读取时间出异常。

getCause(): java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:152)
at java.net.SocketInputStream.read(SocketInputStream.java:122)
at sun.security.ssl.InputRecord.readFully(InputRecord.java:442)
at sun.security.ssl.InputRecord.read(InputRecord.java:480)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:934)
at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:891)
at sun.security.ssl.AppInputStream.read(AppInputStream.java:102)
at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:139)
at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:155)
at org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:284)
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:140)
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:57)
at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:261)
at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:165)
at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:167)
at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:272)
at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:124)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:271)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:220)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:164)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:139)
at com.sample.SampleClient.doGet(SampleClient.java:137)
Run Code Online (Sandbox Code Playgroud)

客户 …

java sockets connection httpclient apache-commons-httpclient

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

PARTITION BY在H2 db中不起作用

我正在使用PARTITION BY子句对结果进行排序。在多列此问题Sql Order by中提到了使用PARTITION BY的详细信息。当我在Oracle中运行时,它工作正常。我在单元测试用例中使用H2 db。当我在H2 db上运行相同的查询时,它不起作用。H2中的已知问题吗?是否有任何其他解决方案可以同时在Oracle和H2中使用。

oracle h2

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

NotSslRecordException: 不是 SSL/TLS 记录

我使用 Redis Spring Data ( 1.8.9.RELEASE) 和 Lettuce ( 4.5.0.Final) 作为底层 Redis 驱动程序。它使用的是 netty 版本4.1.29

我们正在使用启用了传输中加密和静态加密的 Redis ElastiCache。

我得到低于错误。我看到一篇与 netty 相关的帖子NotSslRecordException,其中建议的原因是 http 和 https 不匹配。但是我们用elasticache tcp连接。

Caused by: com.lambdaworks.redis.RedisException: com.lambdaworks.redis.RedisConnectionException: Unable to connect to xxx-redis-xxx-0002-002.-redis-xxx.usw2.cache.amazonaws.com:6379
    at com.lambdaworks.redis.LettuceFutures.await(LettuceFutures.java:130)
    at com.lambdaworks.redis.LettuceFutures.awaitOrCancel(LettuceFutures.java:96)
    at com.lambdaworks.redis.cluster.ClusterFutureSyncInvocationHandler.handleInvocation(ClusterFutureSyncInvocationHandler.java:117)
    at com.lambdaworks.redis.internal.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:80)
    at com.sun.proxy.$Proxy344.hgetall(Unknown Source)
    at org.springframework.data.redis.connection.lettuce.LettuceConnection.hGetAll(LettuceConnection.java:2887)
    ... 53 more
Caused by: com.lambdaworks.redis.RedisConnectionException: Unable to connect to qbo-pprd-redis-rpg-0002-002.qbo-pprd-redis-rpg.jtrqdt.usw2.cache.amazonaws.com:6379
    at com.lambdaworks.redis.RedisConnectionException.create(RedisConnectionException.java:56)
    at com.lambdaworks.redis.cluster.PooledClusterConnectionProvider.lambda$getConnectionAsync$7(PooledClusterConnectionProvider.java:344)
    at java.util.concurrent.CompletableFuture.uniHandle(CompletableFuture.java:822)
    at java.util.concurrent.CompletableFuture$UniHandle.tryFire(CompletableFuture.java:797)
    at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:474)
    at java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:1977)
    at …
Run Code Online (Sandbox Code Playgroud)

java netty spring-data amazon-elasticache spring-data-redis

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

JPQL构造函数表达式 - org.hibernate.hql.ast.QuerySyntaxException:表未映射

我最初的问题是/sf/ask/852083011/ 但找不到任何解决方案,因此使用JPA进行本机查询.entityManager的createNativeQuery返回Query对象,而Query对象又返回List<Object[]>.我不想在迭代列表时处理索引,因为它本质上容易出错.因此我查看了其他解决方案,并发现JPQL的Constructor表达式作为解决方案之一.

表结构是

Schema1 -TableA

 - NameColumn
 - PhoneColumn
Run Code Online (Sandbox Code Playgroud)

对应的Java类是

    public class PersonSearch implements Serializable {

    public PersonSearch (String NameColumn, String PhoneColumn) {
        this.name = NameColumn;
        this.phone = PhoneColumn;
    }

    private String name;

    private String phone;

    public String getName() {
    return name;
    }

    public void setName(String name) {
    this.name = name;
    }

    public String getPhone() {
    return phone;
    }

    public void setPhone(String phone) {
    this.phone = phone;
    }
    }
Run Code Online (Sandbox Code Playgroud)

查询是

 Select NEW com.xyz.PersonSearch(ms.NameColumn, ms.PhoneColumn) From Schema1.TableA ms …
Run Code Online (Sandbox Code Playgroud)

hibernate jpa jpql jpa-2.0

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

遍历对象数组列表

我正在使用本机sql使用以下代码进行查询

private <T> List<T> executeNativeQuery(String queryString,
        Map<String, Object> param, Class<T> clazz) {
    Query query = entityManager.createNativeQuery(queryString);
    if (param != null && param.size() > 0) {
        for (Map.Entry<String, Object> entry : param.entrySet()) {
            query.setParameter(entry.getKey(), entry.getValue());
        }
    }
    List<T> resultList = query.getResultList();
    return resultList;
}
Run Code Online (Sandbox Code Playgroud)

并获得以下数据库结果.

VendorName | IncidentID | IncidentStatus | IncidentDate
-------------------------------------------------------
XYZ        | 100        |     Open       | 02-JUN-2011    
ABC        | 101        |     Closed     | 03-JUN-2011  
MNP        | 102        |     Open       | 01-JUN-2011  
LPQ        | 103        |     Open       | 01-APR-2011 …
Run Code Online (Sandbox Code Playgroud)

java

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

动态数据源路由 - 数据源路由器未初始化

我指的是这篇文章,其中我们可以使用 Spring Framework 中的 AbstractRoutingDataSource 来动态更改应用程序使用的数据源。我正在使用 Mybatis (3.3.0) 和 Spring (4.1.6.RELEASE)。如果从主数据库获取数据时发生异常,我想切换到备份数据库。在这个例子中,我使用了 hsql 和 mysql db。

路由数据源

public class RoutingDataSource extends AbstractRoutingDataSource {

@Override
protected Object determineCurrentLookupKey() {
    return DataSourceContextHolder.getTargetDataSource();
 }
}
Run Code Online (Sandbox Code Playgroud)

数据源上下文持有者

public class DataSourceContextHolder {

private static final ThreadLocal<DataSourceEnum> contextHolder = new ThreadLocal<DataSourceEnum>();

public static void setTargetDataSource(DataSourceEnum targetDataSource) {
    contextHolder.set(targetDataSource);
}

public static DataSourceEnum getTargetDataSource() {
    return (DataSourceEnum) contextHolder.get();
}

public static void resetDefaultDataSource() {
    contextHolder.remove();
 }
}
Run Code Online (Sandbox Code Playgroud)

应用数据配置

@Configuration
@MapperScan(basePackages = "com.sample.mapper")
@ComponentScan("com.sample.config") …
Run Code Online (Sandbox Code Playgroud)

java spring spring-jdbc mybatis spring-mybatis

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

根据窗口大小重新调整文本区域大小

我在弹出窗口中有最大化按钮,我有一个文本区域,并希望根据最大化窗口重新调整大小.下面是打开弹出窗口的代码

var url = "mypopup.do" + params;
var modalprops = "height=310px,width=400px,scrollbars=yes,status=no,menubar=no,resizable=yes";
window.open(url, 'winName', modalprops, false);
Run Code Online (Sandbox Code Playgroud)

javascript

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

没有为响应类MyException找到消息正文编写器

我正在使用Apache-cxf来实现Restful Web服务.如果发生异常,我正在使用ExceptionMapper来构建响应对象.如果发生任何异常,我会收到以下错误.

"没有为响应类MyException找到消息正文编写器."

我可以找到一些建议自定义Writer实现MessageBodyWriter的帖子,但我不太清楚为什么我需要一个自定义编写器,如果为构建响应传递的实体对象(ErrorInfo)是jaxb对象.这可能是一个非常愚蠢的问题,但只是想了解.

@Provider
public class MyExceptionMapper implements
    ExceptionMapper<MyException> {

@Override
public Response toResponse(MyException ex) {
    Response.Status statusCode = exceptionMap.get(ex.getClass());
    ErrorInfo errorInfo=new ErrorInfo();
    errorInfo.setErrorCode(ex.getErrorCode());
    errorInfo.setErrorMessage(ex.getMessage());

    return Response.status(statusCode).entity(ex).build();
    }
}


@XmlRootElement(name = "errorInfo")
@XmlType(propOrder = { "errorCode", "errorMessage"})
public class ErrorInfo {
private String errorCode;
private String errorMessage;


public String getErrorCode() {
    return errorCode;
}
public void setErrorCode(String errorCode) {
    this.errorCode = errorCode;
}
public String getErrorMessage() {
    return errorMessage;
}
public void setErrorMessage(String errorMessage) {
    this.errorMessage = errorMessage;
} …
Run Code Online (Sandbox Code Playgroud)

jax-rs

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