CommonsRequestLoggingFilter在记录请求方面非常好,但就我而言,它在处理请求之前和之后记录相同的内容,这是重复且冗余的。我想摆脱请求后处理日志,但我找不到如何做到这一点。有任何想法吗?
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.filter.CommonsRequestLoggingFilter;
@Configuration
public class RequestLoggingFilterConfig {
@Bean
public CommonsRequestLoggingFilter logFilter() {
CommonsRequestLoggingFilter filter = new CommonsRequestLoggingFilter();
filter.setIncludeClientInfo(true);
filter.setIncludeHeaders(true);
filter.setIncludePayload(false);
filter.setIncludeQueryString(true);
return filter;
}
}
Run Code Online (Sandbox Code Playgroud)
我从这里开始。
以下是我尝试使用 JHipster 生成新项目时得到的错误:
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` succeeded python C:\Program Files\Python36\python.EXE
gyp verb check python version `C:\Program Files\Python36\python.EXE -c "import platform; print(platform.python_version());"` returned: "3.6.4\r\n"
gyp verb could not find "C:\Program Files\Python36\python.EXE". checking python launcher
gyp verb could not find "C:\Program Files\Python36\python.EXE". guessing location
gyp verb ensuring that file exists: …Run Code Online (Sandbox Code Playgroud) 因此,我将我的基本应用程序从Spring Boot 1.5.10迁移到2.0.0.我正在使用Gradle,在迁移之前,我总是排除编译依赖项工件的版本号.迁移后,gradle构建任务开始抛出如下错误:
BUILD FAILED in 0s
2 actionable tasks: 1 executed, 1 up-to-date
During the build, one or more dependencies that were declared without a version failed to resolve:
org.springframework.boot:spring-boot-starter-data-rest:
org.springframework.boot:spring-boot-starter-web:
org.springframework.boot:spring-boot-starter-data-jpa:
Did you forget to apply the io.spring.dependency-management plugin to the llutrackr project?
Run Code Online (Sandbox Code Playgroud)
我build.gradle(我排除了不相关的部分):
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.0.RELEASE")
}
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-data-rest")
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-web')
}
Run Code Online (Sandbox Code Playgroud)
在我将版本号添加到相应的依赖项后,问题就解决了.为什么使用gradle构建Spring Boot 2.0项目需要进行此更改?甚至弹簧指南也不包括工件版本号.一个例子
所以我们在后端使用Spring websocket STOMP + RabbitMQ,我们遇到了打开文件描述符的麻烦.经过一段时间后,我们达到了服务器的限制,服务器不接受任何连接,包括websockets和API端点.
2018-09-14 18:04:13.605 INFO 1288 --- [MessageBroker-1]
o.s.w.s.c.WebSocketMessageBrokerStats : WebSocketSession[2 current WS(2)-
HttpStream(0)-HttpPoll(0), 1159 total, 0 closed abnormally (0 connect
failure, 0 send limit, 63 transport error)], stompSubProtocol[processed
CONNECT(1014)-CONNECTED(1004)-DISCONNECT(0)], stompBrokerRelay[9 sessions,
127.0.0.1:61613 (available), processed CONNECT(1015)-CONNECTED(1005)-
DISCONNECT(1011)], inboundChannel[pool size = 2, active threads = 2, queued
tasks = 2, completed tasks = 12287], outboundChannelpool size = 0, active
threads = 0, queued tasks = 0, completed tasks = 4225], sockJsScheduler[pool
size = 1, active threads = 1, …Run Code Online (Sandbox Code Playgroud) 问题很简单.我<executions></executions>在我的pom.xml中添加了标签,但是我收到了以下错误:
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).
Project ID: MyProject
POM Location: MyPOM
Reason: Parse error reading POM. Reason: Unrecognised tag: 'executions' (position: START_TAG seen ...</version> \t\n\t\t\t\t\t\t <executions>... @2014:23)
for project MyProject
Run Code Online (Sandbox Code Playgroud)
可能是由我使用的Maven版本引起的?我的Maven版本是2.1.0.我找不到"执行"标签的实施时间.没有"执行"标签,一切都很好,我尝试了一些来自网络的代码示例,但也没有用.有任何想法吗?
更具体地说,我想编写一个代码,IllegalArgumentException如果给定值为负,则抛出该代码.我应该在setter/constructor中包含此代码,还是应该在调用适当的方法时检查该值?(如:start(),init(),print()或run().无论)
我的代码(简化):
public class LLUAlgorithm {
private int temperature;
public int getTemperature() {
return temperature;
}
public void setTemperature(int temperature) {
if (temperature < 0)
throw new IllegalArgumentException("can't be smaller than 0.")
this.temperature = temperature;
}
public void run() {
...
}
Run Code Online (Sandbox Code Playgroud)
我不记得一个setter如上所述抛出异常的情况.但我很好奇它是好还是坏.
我的问题很简单.我想在cURL命令中使用环境变量,类似于:
curl -k -X POST -H 'Content-Type: application/json' -d '{"username":"$USERNAME","password":"$PASSWORD"}'
Run Code Online (Sandbox Code Playgroud)
当我运行命令时,$ USERNAME作为"$ USERNAME"字符串传递给命令而不是变量的值.有办法逃避这种情况吗?
谢谢.
SonarQube刚刚在非常基本的Spring Boot应用程序中显示了严重的安全问题。在主要方法上。
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
Run Code Online (Sandbox Code Playgroud)
SonarQube要我 Make sure that command line arguments are used safely here.
我在StackOverflow和Google上都进行了搜索,但令我惊讶的是我找不到关于此问题的任何评论。我几乎可以确定该SpringApplication.run方法内部已经进行了一些安全检查。而且,我什至不记得有人在调用之前清理了主方法的参数SpringApplication.run。我只是想将其标记为误报并继续。
在这里也要问这个问题的一部分:SonarQube在Spring Framework控制器和Spring Framework Application主类中显示安全错误。
是假阳性吗?
我想创建类似的东西
CHECK (ALL(scopes) IN ('read', 'write', 'delete', 'update'))
Run Code Online (Sandbox Code Playgroud)
scopes这是表中的一个字段,text[]我想确保该数组中的所有值都是上述值之一。对此有何意见?是否有可能通过SELECT另一个表获取这些值?
我已经看到了下面的解决方案,但我很好奇是否有更简单的解决方案。
我的问题很简单.我想运行一个Windows命令,每次运行时总是以非零值退出.我无法访问命令本身,并且在调用它时想要操作退出代码.是这样的:
C:\>run.cmd || echo "OK"
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?
提前致谢.
当我简单地使用Grape抓取groovy-ssh插件时,会抛出异常.我使用这里的代码:https://github.com/int128/groovy-ssh
@Grab('org.hidetake:groovy-ssh:1.5.0')
@Grab('ch.qos.logback:logback-classic:1.1.2')
def ssh = org.hidetake.groovy.ssh.Ssh.newService()
println "Test"
BUG! exception in phase 'conversion' in source unit 'delete.groovy' # Licensed to the Apache Software Foundation (ASF) under one or more
Caused by: java.lang.ClassNotFoundException: # Licensed to the Apache Software Foundation (ASF) under one or more
Run Code Online (Sandbox Code Playgroud)
有谁见过这个错误?
java ×3
spring-boot ×3
windows ×2
batch-file ×1
command ×1
command-line ×1
curl ×1
epoll ×1
execution ×1
getter ×1
git ×1
gitignore ×1
gradle ×1
groovy ×1
jenkins ×1
jhipster ×1
linux ×1
logging ×1
maven ×1
netty ×1
oop ×1
pom.xml ×1
postgresql ×1
python ×1
setter ×1
shell ×1
sonarqube ×1
spring ×1
sql ×1
ssh ×1
stomp ×1
tags ×1
unix ×1