该类的Oracle Tutorial页面Instant显示了此示例代码:
Instant oneHourLater = Instant.now().plusHours(1);
Run Code Online (Sandbox Code Playgroud)
当我尝试编译此代码时,编译器抛出错误:
InstantPrint.java:6: error: cannot find symbol
Instant oneHourLater = Instant.now().plusHours(1);
^
symbol: method plusHours(int)
location: class Instant
但是这个Java文档提到了plusHours()方法,但我检查了这个Instant类,它不包含plusHours()方法.
此后,为什么plusHours()在这个例子中提到这个方法呢?
我知道,这是重复的问题,但问题是新的,请不要标记重复的问题.这个程序在Window 10中运行它运行正常并创建一个数据库,但是当在Debian 9中运行相同的程序时它会抛出异常.之后,我在谷歌上检查了这个问题.有人说,创建一个所有用户类状态的setter和getter方法.我创建了一个setter和getter方法,但抛出了同样的异常.
用户类
@Entity
public class User {
@Id
private Long id;
private String firstName;
private String lastName;
private String professional;
private int age;
public User() {}
public User(Long id, String firstName, String lastName, String professional, int age) {
this.id = id;
this.firstName = firstName;
this.lastName = lastName;
this.professional = professional;
this.age = age;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getFirstName() {
return firstName;
}
public …Run Code Online (Sandbox Code Playgroud) 更新到1.19.1后,我不断收到此错误。 磁盘上的内容是较新的。单击比较以将您的版本与磁盘上的版本进行比较。
我正在为断路器编写一个小程序,运行该应用程序时会抛出异常。
springboot 版本 2.5.4,Hystrix 版本使用2.2.6
BeanCreationException:创建类路径资源 [org/springframework/cloud/autoconfigure/ConfigurationPropertiesRebinderAutoConfiguration.class] 中定义的名为“configurationPropertiesBeans”的 bean 时出错:合并 bean 定义的后处理失败;嵌套异常是 java.lang.IllegalStateException:无法从 ClassLoader [jdk.internal.loader.ClassLoaders$AppClassLoader@659e0bfd] 内省类 [org.springframework.cloud.context.properties.ConfigurationPropertiesBeans]
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.4</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.ramgovindhare</groupId>
<artifactId>cricuitbreakerhystrix</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>CricuitBreakerHystrix</name>
<description>firstMicroserviceProject</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-netflix-hystrix -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
<version>2.2.8.RELEASE</version> <--- **See this**
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build> …Run Code Online (Sandbox Code Playgroud) 我创建了一个简单的 Spring REST 服务(POST、PUT)。但是当我从邮递员调用此服务时,值存储在null中。
学生Pojo班
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import org.springframework.hateoas.ResourceSupport;
@SuppressWarnings("serial")
@Entity
@Table(schema="fishpool")
public class Student extends ResourceSupport implements Serializable {
@Id @GeneratedValue(strategy=GenerationType.AUTO)
private Long sId;
private String name;
private String email;
public Student() {
}
public Student(Long sId, String name, String email) {
this.sId = sId;
this.name = name;
this.email = email;
}
public Long getsId() {
return sId;
}
public void setsId(Long sId) {
this.sId …Run Code Online (Sandbox Code Playgroud) 请任何人解释一下为什么允许导入模块描述符文件?
模块描述符文件中的语句的用途是什么import。
import java.util.*;
module superman {
}
Run Code Online (Sandbox Code Playgroud) 我的应用程序正在运行,但是什么时候,我遇到应用程 我曾多次尝试过同样的事情.我检查了数据库连接,一切都很好.这些是我的日志
例外
Caused by: java.lang.IllegalArgumentException: URL must start with 'jdbc'
at org.springframework.util.Assert.isTrue(Assert.java:116) ~[spring-core-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.boot.jdbc.DatabaseDriver.fromJdbcUrl(DatabaseDriver.java:268) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.determineDriverClassName(DataSourceProperties.java:230) ~[spring-boot-autoconfigure-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.initializeDataSourceBuilder(DataSourceProperties.java:176) ~[spring-boot-autoconfigure-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration.createDataSource(DataSourceConfiguration.java:43) ~[spring-boot-autoconfigure-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Hikari.dataSource(DataSourceConfiguration.java:81) ~[spring-boot-autoconfigure-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_161]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_161]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_161]
at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_161]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
... 40 common frames omitted
Run Code Online (Sandbox Code Playgroud)
application.properties
#======================
# DATA SOURCE
#=====================
spring.datasource.url="jdbc:mysql://localhost:3306/customerdb?useSSL=false"
spring.datasource.username=root
spring.datasource.password=root
#spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.dbcp2.test-while-idle=true
spring.datasource.dbcp2.validation-query= SELECT 1
#============================
# JPA/Hibernate
#===========================
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
spring.jpa.hibernate.naming.physical-strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
#===================================================================
# Spring Security / …Run Code Online (Sandbox Code Playgroud) 可能一切正常,但我收到错误。基本上我在应用程序属性文件中添加视图解析器属性,然后运行这个项目并打开浏览器,浏览器显示此错误Whitelabel Error Page 404 file not found。我不明白帮助我并建议如何解决这个问题,我是 Spring Boot 的新手。在这打击我的项目细节的 .
错误
2018-04-07 12:11:51.661 DEBUG 3740 --- [nio-8080-exec-1] o.s.w.s.v.ContentNegotiatingViewResolver : Returning [org.springframework.web.servlet.view.InternalResourceView: name 'home'; URL [/WEB-INF/jsp/home.jsp]] based on requested media type 'text/html'
2018-04-07 12:11:51.661 DEBUG 3740 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Rendering view [org.springframework.web.servlet.view.InternalResourceView: name 'home'; URL [/WEB-INF/jsp/home.jsp]] in DispatcherServlet with name 'dispatcherServlet'
2018-04-07 12:11:51.661 TRACE 3740 --- [nio-8080-exec-1] o.s.w.servlet.view.InternalResourceView : Rendering view with name 'home' with model {} and static attributes {}
2018-04-07 12:11:51.684 DEBUG 3740 --- [nio-8080-exec-1] …Run Code Online (Sandbox Code Playgroud) 当我运行第一段时,它非常好并生成一个输出。但是在第二种情况下,当我运行此段 2 时,它会生成
DateTimeException : Unable to extract ZoneId from temporal.
Run Code Online (Sandbox Code Playgroud)
第 1 部分:
LocalDate ld = LocalDate.now();
System.out.println(DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL).format(ld));
Run Code Online (Sandbox Code Playgroud)
第 2 部分:
LocalDateTime ldt = LocalDateTime.now();
DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL);
System.out.println(dtf.format(ldt));
Run Code Online (Sandbox Code Playgroud) 当编译安全帽项目时,当它显示Nothing to Compile时。
{
"name": "HardhAtToken",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@nomiclabs/hardhat-ethers": "^2.0.6",
"@nomiclabs/hardhat-waffle": "^2.0.3",
"chai": "^4.3.6",
"ethereum-waffle": "^3.4.4",
"ethers": "^5.6.6",
"hardhat": "^2.9.6-dev.1"
},
"dependencies": {
"glob": "^7.2.0"
}
}
Run Code Online (Sandbox Code Playgroud) 问题:如何获取位置https://github.com/TEK-Leads/Config-Properties.git中的数据
当我尝试运行此应用程序时,它不显示任何结果,它只显示默认的传递结果(请参阅MessageController)。或显示此类消息的 ConfigClient 端日志。
无法找到 PropertySource:“http://localhost:8888/application/default”的 GET 请求发生 I/O 错误:连接被拒绝;嵌套异常是 java.net.ConnectException: 连接被拒绝
当将配置服务器端application.yml文件更改为bootstrap.yml时,抛出下面的异常时。
If you are using the git profile, you need to set a Git URI in your configuration. If you have set spring.cloud.config.server.bootstrap=true, you need to use a composite configuration.
Run Code Online (Sandbox Code Playgroud)
配置服务器部分
Pom.xml
<properties>
<java.version>11</java.version>
<spring-cloud.version>2020.0.3</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement> …Run Code Online (Sandbox Code Playgroud) 我尝试显示数组数据,但在 React 网页上不显示数据。任何人都指导我哪里有错误并纠正我。请参阅评论行//
/* eslint-disable */
import React, { Component } from 'react';
import axios from 'axios';
class RestaurantList extends Component<{}, any> {
constructor(props: any) {
super(props);
this.state = { restoLists: null };
}
componentDidMount() {
axios.get("http://localhost:3030/restauranst")
.then((response) => {
this.setState({ restoLists: response.data })
console.log(response);
})
.catch((error) => console.error(error));
}
render() {
console.log(this.state.restoLists);
return (
<div>
<h1>RestaurantList</h1>
{
this.state.restoLists ?
<div>
<ul>
{
this.state.restoLists.map((itme: any) => {
console.log(itme.name); // work this line
<li>
{itme.name} {/**Does not work this line …Run Code Online (Sandbox Code Playgroud) java ×8
spring ×6
spring-boot ×6
java-11 ×2
java-time ×2
spring-mvc ×2
datasource ×1
ethereum ×1
hardhat ×1
hibernate ×1
hystrix ×1
ide ×1
java-module ×1
json ×1
module-info ×1
npm ×1
reactjs ×1
solidity ×1
spring-data ×1
spring-rest ×1
typescript ×1