小编Dav*_*ams的帖子

无法识别MySQL defaults-file参数

我试图在命令行上使用--defaults-file选项登录mysql:

$ mysql --defaults-file ~/mycnf.cnf
Run Code Online (Sandbox Code Playgroud)

但是我收到以下错误:

mysql: unknown option '--defaults-file'
Run Code Online (Sandbox Code Playgroud)

但是这个选项列在帮助中:

$ mysql --help
...
Default options are read from the following files in the given order:
/etc/mysql/my.cnf /etc/my.cnf ~/.my.cnf
The following groups are read: mysql client
The following options may be given as the first argument:
--print-defaults        Print the program argument list and exit.
--no-defaults           Don't read default options from any option file.
--defaults-file=#       Only read default options from the given file #.
--defaults-extra-file=# Read this file after the …
Run Code Online (Sandbox Code Playgroud)

mysql

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

Apache - Init:无法打开服务器私钥文件

我在运行localhost的apache上启用了ssl.我生成了一个自签名证书并将其放在通常的位置:

[david@david web]$ ll /etc/ssl/certs/
...
-rwxrwxrwx. 1 david david    977 Mar  7 13:18 localhost.crt
-rwxrwxrwx. 1 david david    712 Mar  7 13:16 localhost.csr
-rwxrwxrwx. 1 david david    963 Mar  7 13:12 localhost.key
Run Code Online (Sandbox Code Playgroud)

但是当我重新启动Apache时,服务器出现故障,我在错误日志中收到以下内容:

[Fri Mar 07 13:29:17 2014] [notice] SELinux policy enabled; httpd running as context unconfined_u:system_r:httpd_t:s0
[Fri Mar 07 13:29:17 2014] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Fri Mar 07 13:29:17 2014] [error] (13)Permission denied: Init: Can't open server private key file /etc/ssl/certs/localhost.key
Run Code Online (Sandbox Code Playgroud)

权限对我来说没问题,我做错了什么?

apache ssl httpd.conf suexec

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

Jersey:ContainerRequestFilter没有获得Context ServletRequest

要查看此问题的完整代码,请参阅此github

https://github.com/mobiusinversion/web-application

我也创造了这个泽西吉拉

https://java.net/jira/browse/JERSEY-2851

我正在ContainerRequestFilter使用Jersey 2.15.这是一个嵌入式Jetty应用程序,它被遮蔽成一个罐子.

在Jetty启动器(主类)中:

public static void main(String[] args) throws Exception {
    ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
    context.setContextPath("/");
    Server jettyServer = new Server(10005);
    jettyServer.setHandler(context);
    ServletHolder jerseyServlet = context.addServlet(ServletContainer.class, "/*");
    jerseyServlet.setInitOrder(0);
    jerseyServlet.setInitParameter(ServerProperties.PROVIDER_PACKAGES, ServletConstants.COMPONENT_SCAN_ROOT);

    try {
        System.out.println("Starting Jetty");
        jettyServer.start();
        System.out.println("Jetty Started");
        jettyServer.join();
    } catch (Exception e) {
        System.out.println("Could not start server");
        e.printStackTrace();
    } finally {
        jettyServer.destroy();
    }
}
Run Code Online (Sandbox Code Playgroud)

我有一个过滤器,通过提供商包括在内

@Provider
public class ExampleProvider implements DynamicFeature {

    @Override
    public void configure(ResourceInfo resourceInfo, FeatureContext featureContext) {
        ExampleFilter exampleFilter = …
Run Code Online (Sandbox Code Playgroud)

java jetty ip-address jersey servlet-filters

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

Java/Wicket:使用Resources编译Basic Hello World

我正在关注Hello World Wicket应用程序的这个示例

https://www.ibm.com/developerworks/web/library/wa-aj-wicket/

特别是我放在HelloWorld.html我的源目录旁边HelloWorld.java.

我的文件结构如下所示:

$ tree
.
??? pom.xml
??? src
?   ??? main
?   ?   ??? java
?   ?   ?   ??? com
?   ?   ?       ??? example
?   ?   ?           ??? wicket
?   ?   ?               ??? HelloWorld.html
?   ?   ?               ??? HelloWorld.java
?   ?   ?               ??? HelloWorldApplication.java
?   ?   ??? resources
?   ?   ??? webapp
?   ?       ??? WEB-INF
?   ?           ??? web.xml
?   ??? test
?       ??? java
??? wicketTest.iml 
Run Code Online (Sandbox Code Playgroud)

但是,当我将其编译为war文件,并在Jetty中加载时,我在浏览器中收到此错误:

Unexpected …
Run Code Online (Sandbox Code Playgroud)

java wicket maven

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

Kafka快速入门:我需要哪些依赖关系?

我正在通过kafka快速入门:

http://kafka.apache.org/07/quickstart.html

和基本的消费者群体示例:

https://cwiki.apache.org/confluence/display/KAFKA/Consumer+Group+Example

我已经编写了Consumer和ConsumerThreadPool,如上所示:

import kafka.consumer.KafkaStream;
import kafka.consumer.ConsumerIterator;

public class Consumer implements Runnable {

    private KafkaStream m_stream;
    private Integer m_threadNumber;

    public Consumer(KafkaStream a_stream, Integer a_threadNumber) {
        m_threadNumber = a_threadNumber;
        m_stream = a_stream;
    }

    public void run() {
        ConsumerIterator<byte[], byte[]> it = m_stream.iterator();
        while (it.hasNext()) {
            System.out.println("Thread " + m_threadNumber + ": " + new String(it.next().message()));

        }
        System.out.println("Shutting down Thread: " + m_threadNumber);
    }
}
Run Code Online (Sandbox Code Playgroud)

其他几个方面:我使用spring来管理我的zookeeper:

import javax.inject.Named;
import java.util.Properties;
import kafka.consumer.ConsumerConfig;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@Configuration
@ComponentScan("com.truecar.inventory.worker.core") …
Run Code Online (Sandbox Code Playgroud)

java log4j scala noclassdeffounderror maven

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

AWS RDS:如何连接到实例

我刚刚设置了一个Amazon RDS实例.我有一个单独的应用程序服务器,我试图找出如何从我的EC2应用程序服务器连接到RDS实例.在Instance页面上,我有

enbdpoint: mycompany.czdv3mj7ps25.us-west-2.rds.amazonaws.com:5432
Run Code Online (Sandbox Code Playgroud)

我尝试使用该地址登录到psql,但我得到了

$ psql -h mycompany.czdv3mj7ps25.us-west-2.rds.amazonaws.com:5432 -U myuser -d mydb
psql: could not translate host name "mycompany.czdv3mj7ps25.us-west-2.rds.amazonaws.com:5432" to address: Name or service not known
Run Code Online (Sandbox Code Playgroud)

如何连接到实例数据库?我没有在RDS控制台中看到任何其他IP地址.

postgresql amazon-ec2 amazon-web-services amazon-rds

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

IPython:为所有请求配置基本URL路径

我试图弄清楚如何配置运行的IPython笔记本服务器的基本URL.而不是默认值:

#request# GET http://localhost:8888/static/tree/js/main.min.js?v=04a28c5e21950738efb217191f08ac33
#request# GET http://localhost:8888/api/terminals?_=1441754529652
#request# GET http://localhost:8888/custom/custom.js?v=20150908160654
#request# GET http://localhost:8888/notebooks/Untitled1.ipynb?kernel_name=python3#
Run Code Online (Sandbox Code Playgroud)

我想配置所有请求,以便通过ipython,如:

#request# GET http://localhost:8888/ipython/static/tree/js/main.min.js?v=04a28c5e21950738efb217191f08ac33
#request# GET http://localhost:8888/ipython/api/terminals?_=1441754529652
#request# GET http://localhost:8888/ipython/custom/custom.js?v=20150908160654
#request# GET http://localhost:8888/ipython/notebooks/Untitled1.ipynb?kernel_name=python3#
Run Code Online (Sandbox Code Playgroud)

这可能吗?

python ipython

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

如何从TimeZone String ID和Epoch实例化Joda DateTime

我正在看看Joda Time图书馆.我试图弄清楚如何在给定时间戳和时区的情况下构造DateTime对象.我希望这能让我在那个时区找到那个星期几,那天如何等等.但是,我不确定如何将DateTimeZone传递给DateTime构造函数.

import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.Instant;

public class TimeZoneTest {

    public static void main (String[] args) {

        long epoch = System.currentTimeMillis()/1000;

        DateTimeZone tz = new DateTimeZone( "America/New_York" );

        DateTime dt = new DateTime( epoch, tz );

        System.out.println( dt );
    }

}
Run Code Online (Sandbox Code Playgroud)

我尝试了上面的"America/New_York"的硬编码示例,但是从编译器中得到了这个.我究竟做错了什么?

$ javac -cp "joda-time-2.2.jar:." TimeZoneTest.java
    TimeZoneTest.java:12: org.joda.time.DateTimeZone is abstract; cannot be instantiated
    DateTimeZone tz = new DateTimeZone( "America/New_York" );
                      ^
    1 error
Run Code Online (Sandbox Code Playgroud)

java time timezone datetime jodatime

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

泽西岛:如何将杰克逊添加到Servlet Holder

我正在使用Jersey创建一个嵌入式Jetty webapp.我不知道如何在这里添加杰克逊自动JSON serde:

    ServletHolder jerseyServlet = context.addServlet(
       org.glassfish.jersey.servlet.ServletContainer.class, "/*");
    jerseyServlet.setInitOrder(0);

    jerseyServlet.setInitParameter(
        ServerProperties.PROVIDER_CLASSNAMES,
        StringUtils.join(
            Arrays.asList(
                HealthCheck.class.getCanonicalName(),
                Rest.class.getCanonicalName()),
            ";"));

    // Create JAX-RS application.
    final Application application = new ResourceConfig()
        .packages("com.example.application")
        .register(JacksonFeature.class);

    // what do I do now to tie this to the ServletHolder?
Run Code Online (Sandbox Code Playgroud)

如何ResourceConfig在ServletHolder中注册这个,以便在使用注释的地方使用Jackson @Produces(MediaType.APPLICATION_JSON)?这是嵌入式Jetty应用程序的完整主类

package com.example.application.web;

import com.example.application.api.HealthCheck;
import com.example.application.api.Rest;
import com.example.application.api.Frontend;
import org.apache.commons.lang.StringUtils;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.glassfish.jersey.jackson.JacksonFeature;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.server.ServerProperties;

import javax.ws.rs.core.Application;
import java.util.Arrays;

public class JettyStarter {

public static void main(String[] …
Run Code Online (Sandbox Code Playgroud)

java jetty jersey embedded-jetty jackson

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

mvn依赖:tree并不真正显示所有依赖项

我遇到了一个问题,编译了一个包含许多依赖关系的jar,特别是重叠版本snakeyaml(我们需要1.11,一些依赖关系在1.9中引入).我们跑了,mvn dependency:tree但我们没有在任何输出中看到有问题的二级版本.在进一步检查时,那是否正在jruby-complete进入snakeyaml.为什么没有mvn dependency:tree向我们展示这种级别的向下钻取:

[INFO] |     |  +- org.apache.hbase:hbase-it:jar:0.98.6-cdh5.2.5:compile
[INFO] |     |  |  +- (org.apache.hbase:hbase-common:jar:0.98.6-cdh5.2.5:compile - omitted for duplicate)
[INFO] |     |  |  +- (org.apache.hbase:hbase-protocol:jar:0.98.6-cdh5.2.5:compile - omitted for duplicate)
[INFO] |     |  |  +- (org.apache.hbase:hbase-client:jar:0.98.6-cdh5.2.5:compile - omitted for duplicate)
[INFO] |     |  |  +- org.apache.hbase:hbase-shell:jar:0.98.6-cdh5.2.5:compile
[INFO] |     |  |  |  +- (org.apache.hbase:hbase-common:jar:0.98.6-cdh5.2.5:compile - omitted for duplicate)
[INFO] |     |  |  |  +- (org.apache.hbase:hbase-protocol:jar:0.98.6-cdh5.2.5:compile - omitted for duplicate)
[INFO] |     |  | …
Run Code Online (Sandbox Code Playgroud)

java tree maven

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