我从一些测验中提取了此代码段,使用IDE执行了该代码段,并获得了长久的结果,但是正确的答案是Byte,Byte,为什么我得到不同的结果?这个问题与JDK 11有关
public class Client {
static void doCalc(byte... a) {
System.out.print("byte...");
}
static void doCalc(long a, long b) {
System.out.print("long, long");
}
static void doCalc(Byte s1, Byte s2) {
System.out.print("Byte, Byte");
}
public static void main(String[] args) {
byte b = 5;
doCalc(b, b);
}
}
Run Code Online (Sandbox Code Playgroud)
编辑:
代码在此处获取:Oracle认证概述和样本问题 (页面:13,问题:5)
我想配置Spring Batch作业,但是我收到错误,我无法理解是什么意思?
读者:
import org.springframework.batch.item.ItemReader;
public class MoviesReader implements ItemReader<SearchResponseRO>, StepExecutionListener {
@Override
public SearchResponseRO read() throws Exception {
return new SearchResponseRO();
}
}
Run Code Online (Sandbox Code Playgroud)
处理器:
import org.springframework.batch.item.ItemProcessor;
public class MoviesProcessor implements ItemProcessor<SearchResponseRO, Movie> {
@Override
public Movie process(SearchResponseRO searchResponseRO) throws Exception {
return new Movie();
}
}
Run Code Online (Sandbox Code Playgroud)
我需要更改并修复错误?
谢谢.
我有一个带有 JSON 类型列的表,表中有 1 行。以下请求显示结果20761字节:
SELECT pg_column_size(test_column) FROM test_table;
Run Code Online (Sandbox Code Playgroud)
test_column 的值有 size 个45888字节,因此这意味着 PostgreSQL 压缩了该数据,但压缩了45888/20761=~2.1多次。如何对 JSON 类型进行比现有值更多的压缩?
我想使用页面thymeleaf.但我对静态文件有一些问题.我研究了问题(1,2,3有类似的问题),但它并不能帮助我.
我Spring Boot在应用程序中使用了一个框架.我的文件看起来像:

的test.html
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<script src="js/test.js" th:src="@{/test.js}"/>
</head>
<body>
<button onclick="testFunction('test value')">Button</button>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
test.js
function testFunction(test) {
console.log(test);
}
Run Code Online (Sandbox Code Playgroud)
配置类
@Configuration
@EnableWebMvc
public class WebMvcConfig extends WebMvcConfigurerAdapter {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/**").addResourceLocations("classpath:/static/js/");
super.addResourceHandlers(registry);
}
}
Run Code Online (Sandbox Code Playgroud)
和问题,当我加载test.html文件没有加载javascript.
@GetMapping(value = "web/test")
public String getTestHtmlPage() {
return "test";
}
Run Code Online (Sandbox Code Playgroud)
/api/v1 是一个配置 application.properties => server.servlet-path=/api/v1
我做错了什么?你能帮助我吗?
谢谢大家!
我有一个在本地(不在容器中)9000 端口上运行的 Spring Boot 应用程序。该应用程序已使用 Prometheus 千分尺配置执行器,并且可以通过 URL localhost:9000/actuator/prometheus 获取整个统计数据。
\n\n我使用以下命令在 Docker 容器中运行 Prometheus:
\n\ndocker run --name spring_boot_prometheus -p 9090:9090 -p 9000:9000 -v /Users/xyz/docker/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus\nRun Code Online (Sandbox Code Playgroud)\n\n普罗米修斯.yml
\n\nglobal:\n scrape_interval: 5s\n evaluation_interval: 5s\nscrape_configs:\n- job_name: \'users-app\'\n metrics_path: \'/actuator/prometheus\'\n static_configs:\n - targets: [\'localhost:9000\']\nRun Code Online (Sandbox Code Playgroud)\n\n该命令docker ps返回以下内容:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES\n1568ec9e8353 prom/prometheus "/bin/prometheus --c\xe2\x80\xa6" 10 seconds ago Up 9 seconds 0.0.0.0:9000->9000/tcp, 0.0.0.0:9090->9090/tcp spring_boot_prometheus\nRun Code Online (Sandbox Code Playgroud)\n\nUI 表示 prometheus 无法连接到 spring boot 端点,但它可用。如果我单击端点,它会将我重定向到1568ec9e8353:9000而不是localhost:9000 …
我有几个application-x.properties用于不同配置文件的文件,每个文件都包含一个属性,每个属性都有特定的值。我想在查询数据库中使用此属性作为参数。
可以使用SpEL或其他方式添加它吗?
例如application.properties:
query.parameters.role: ADMIN
Run Code Online (Sandbox Code Playgroud)
可能的用法:
query.parameters.role: ADMIN
Run Code Online (Sandbox Code Playgroud) 我正在开发将从用户接收文件然后上传到 Amazon S3 的应用程序。使用 API Gateway 访问应用程序。服务 API 网关对 WebSocket 和 REST API 的负载大小有限制。有什么方法可以通过 API Gateway 从 Internet 访问我的服务?
我的Spring Boot项目中有几个带有SQL查询的文件.这些查询按路径定位
spring-boot-sql-in-files/src/main/resources/sql/query.sql
Run Code Online (Sandbox Code Playgroud)
当我运行我的应用程序时,我执行这些查询加载到静态变量.
private static final String PATH_PREFIX = "src/main/resources/sql/";
public static String loadQueryFromFile(@NonNull String fileName) {
try {
return FileUtils.readFileToString(new File(PATH_PREFIX + fileName), Charset.defaultCharset());
} catch (Exception e) {
log.error("Error occurred during loading sql file to string, file=" + fileName, e);
throw new QueryNotLoadedException();
}
}
Run Code Online (Sandbox Code Playgroud)
当我使用IDE运行它时工作正常,但是当我运行name.jar文件时它不起作用,我得到以下错误:
java.io.FileNotFoundException: File 'src/main/resources/sql/query.sql' does not exist
Run Code Online (Sandbox Code Playgroud)
我该如何修复这条路?
我有使用 jpa 框架连接到数据库的 java 应用程序。对象UserInformation包含AdditionData对象,当我userInformationRepository.findByUserId(id)收到错误时。作为回应,我看到带有许多内部对象的 json
userInformation->additionData->userInformation->userInformation->additionData->userInformation->....
Run Code Online (Sandbox Code Playgroud)
例外:
>java.lang.StackOverflowError: null
Method threw 'java.lang.StackOverflowError' exception. Cannot evaluate com.entity.UserInformation.toString()
java.lang.StackOverflowError: null
at javax.servlet.ServletResponseWrapper.getBufferSize(ServletResponseWrapper.java:167) ~[tomcat-embed-core-8.5.6.jar:8.5.6]
at javax.servlet.ServletResponseWrapper.getBufferSize(ServletResponseWrapper.java:167) ~[tomcat-embed-core-8.5.6.jar:8.5.6]
at org.springframework.security.web.util.OnCommittedResponseWrapper.checkContentLength(OnCommittedResponseWrapper.java:232) ~[spring-security-web-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.security.web.util.OnCommittedResponseWrapper.access$200(OnCommittedResponseWrapper.java:33) ~[spring-security-web-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.security.web.util.OnCommittedResponseWrapper$SaveContextServletOutputStream.write(OnCommittedResponseWrapper.java:637) ~[spring-security-web-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at com.fasterxml.jackson.core.json.UTF8JsonGenerator._flushBuffer(UTF8JsonGenerator.java:2033) ~[jackson-core-2.8.4.jar:2.8.4]
at com.fasterxml.jackson.core.json.UTF8JsonGenerator.writeRaw(UTF8JsonGenerator.java:632) ~[jackson-core-2.8.4.jar:2.8.4]
at com.fasterxml.jackson.core.json.UTF8JsonGenerator.writeRaw(UTF8JsonGenerator.java:555) ~[jackson-core-2.8.4.jar:2.8.4]
at com.fasterxml.jackson.core.json.UTF8JsonGenerator.writeNumber(UTF8JsonGenerator.java:931) ~[jackson-core-2.8.4.jar:2.8.4]
at com.fasterxml.jackson.databind.ser.std.NumberSerializers$FloatSerializer.serialize(NumberSerializers.java:194) ~[jackson-databind-2.8.4.jar:2.8.4]
at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:704) ~[jackson-databind-2.8.4.jar:2.8.4]
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:690) ~[jackson-databind-2.8.4.jar:2.8.4]
at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:155) ~[jackson-databind-2.8.4.jar:2.8.4]
at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:704) ~[jackson-databind-2.8.4.jar:2.8.4]
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:690) ~[jackson-databind-2.8.4.jar:2.8.4]
at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:155) ~[jackson-databind-2.8.4.jar:2.8.4]
at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:704) ~[jackson-databind-2.8.4.jar:2.8.4]
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:690) ~[jackson-databind-2.8.4.jar:2.8.4]
at …Run Code Online (Sandbox Code Playgroud) java ×5
spring-boot ×4
json ×2
spring ×2
docker ×1
postgresql ×1
prometheus ×1
spring-batch ×1
thymeleaf ×1