我在我的java应用程序中使用log4j 2.3.我通过maven添加了依赖项.
在eclipse中运行程序时一切正常,但是当我用maven打包并尝试运行jar时,我得到以下错误:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache logging/log4j/LogManager
at main.myclass.<clinit>(myclass.java:11)
Caused by: java.lang.ClassNotFoundException: org.apache.logging.log4j.LogManager
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more
Run Code Online (Sandbox Code Playgroud)
为什么从jar运行它时无法找到类?
添加log4j 1.2也不起作用.该程序在eclipse中正常运行,因此不应缺少依赖项.
我已经使用以下配置在 docker 容器中成功运行了json-server一段时间:
码头工人文件:
FROM node:alpine
EXPOSE 3000
COPY deploy/conf/mockBackend.json /opt/mockBackend.json
RUN yarn global add json-server
CMD ["json-server", "/opt/mockBackend.json"]
Run Code Online (Sandbox Code Playgroud)
运行命令:
docker run -d -p 3000:3000 --name mockbackend mockbackend
Run Code Online (Sandbox Code Playgroud)
最近这停止工作。我进入ERR_CONNECTION_REFUSED
浏览器。
默认情况下 json-server 绑定到127.0.0.1,如果这是正确的,这可能会导致此问题。
我不知道为什么它以前工作过,但是将 json 服务器绑定到每个接口json-server -H 0.0.0.0 mockBackend.json使其再次工作。
我现在的问题是json-server手动在图像中以这种方式启动工作正常,但是当我CMD将 Dockerfile的行更改为以下CMD ["json-server", "-H 0.0.0.0", "/opt/mockBackend.json"]错误时:
码头工人日志:
\{^_^}/ hi!
Loading /opt/mockBackend.json
Done
Resources
http:// 0.0.0.0:3000/xxx
http:// 0.0.0.0:3000/yyy
Home
http:// 0.0.0.0:3000
Type s + enter at any …Run Code Online (Sandbox Code Playgroud) 我有一个基于的服务器ThreadingTCPServer.现在我想要为该服务器添加SSL支持.没有SSL它工作正常,但使用SSLv3我无法将客户端连接到服务器,它总是抛出一个异常:Error 111 Connection Refused.错误是该端口上没有SSL服务器.
我根据Stackoverflow上的示例添加了SSL支持.这是我的代码:
服务器:
class BeastServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer):
def __init__(self, server_address, RequestHandlerClass, bind_and_activate=True):
SocketServer.BaseServer.__init__(self, server_address,
RequestHandlerClass)
ctx = SSL.Context(SSL.SSLv3_METHOD)
cert = 'server.pem'
key = 'key.pem'
ctx.use_privatekey_file(key)
ctx.use_certificate_file(cert)
self.socket = SSL.Connection(ctx, socket.socket(self.address_family,
self.socket_type))
if bind_and_activate:
#self.server_bind()
#self.server_a
Run Code Online (Sandbox Code Playgroud)
客户:
class Client(object) :
def verbinden (self, ip_) :
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
ssl_sock = ssl.wrap_socket(s, cert_reqs=ssl.CERT_REQUIRED,
ssl_version=ssl.PROTOCOL_SSLv3, ca_certs='server.pem')
ssl_sock.connect((ip_, 10012))
return ssl_sock
Run Code Online (Sandbox Code Playgroud)
密钥和证书文件是使用开放SSL创建的.我希望有人能告诉我问题是什么.
谢谢你的帮助
最好的问候帕特里克
In my spring controller I return a ResponseStatusException if no entity is found, like this:
@GetMapping("/categories/{id}")
public ResponseEntity<Category> getCategoryById(@PathVariable(value = "id") String id) {
try {
return new ResponseEntity<Category>(categoryService.findById(id), HttpStatus.OK);
} catch (CategoryNotFoundException ex) {
throw new ResponseStatusException(HttpStatus.NOT_FOUND, ex.getMessage());
}
}
Run Code Online (Sandbox Code Playgroud)
I would expect the answer to be something like:
{
"timestamp": "2019-02-22T12:25:29.913+0000",
"status": 404,
"error": "Not Found",
"message": "could not find category with ID: XYZ'.",
"path": "/categories/XYZ"
}
Run Code Online (Sandbox Code Playgroud)
But the response also includes a long field "trace" with the …
docker ×1
eclipse ×1
java ×1
javascript ×1
json-server ×1
log4j2 ×1
maven ×1
python ×1
socketserver ×1
spring-boot ×1
ssl ×1