在Spring Data REST(通过Spring Boot 1.3.3)中,当我GET是资源集合时people,该@Version属性不包含在资源中:
$curl -v http://localhost:8080/api/people/1
* Trying ::1...
* Connected to localhost (::1) port 8080 (#0)
> GET /api/people/1 HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.42.1
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: Apache-Coyote/1.1
< ETag: "0"
< Last-Modified: Tue, 26 Apr 2016 00:08:12 GMT
< Content-Type: application/hal+json;charset=UTF-8
< Transfer-Encoding: chunked
< Date: Tue, 26 Apr 2016 00:12:56 GMT
<
{
"id" : 1,
"createdDate" : {
"nano" …Run Code Online (Sandbox Code Playgroud) 我在我的应用程序中使用spring-data-rest.我使用configureRepositoryRestConfiguration配置了repositoryRest
我在此配置中添加了以下两行
config.exposeIdsFor(Person.class);
config.setDefaultMediaType(MediaType.APPLICATION_JSON_UTF8);
config.useHalAsDefaultJsonMediaType(false);
Run Code Online (Sandbox Code Playgroud)
在添加此配置之前,我的响应如下所示
{
"_embedded": {
"persons": []
},
"_links": {
"self": {
"href": "http://192.168.2.42:8082/persons/search/findByGroupId?groupId=44"
}
}
}
Run Code Online (Sandbox Code Playgroud)
我可以按预期使用RestTemplate获取空人列表.但是在添加上面的配置之后,我得到了以下响应结构
{
"links": [{
"rel": "self",
"href": "http://localhost:8082/persons/search/findByGroupId?groupId=44"
}],
"content": [{
"collectionValue": true,
"relTargetType": "com.myapp.example.domain.Person",
"value": []
}]
}
Run Code Online (Sandbox Code Playgroud)
使用此响应RestTemplate返回一个大小为1的列表,其中包含null我域中所有属性的值.
任何人都可以帮助获得这种结构的空列表.
我使用以下代码从API获取响应:
restTemplate.exchange(
url,
GET,
HttpEntity.EMPTY,
parameterizedTypeReference<Resources<Person>>,
Collections.emptyMap()
);
Run Code Online (Sandbox Code Playgroud)
更新:
这是一个spring-data-rest bug.因为某处代码,而不是Person,EmbeddedWrapper用作域类型.调查代码后,我发现"collectionValue","relTargetType"和"value"在JSON响应是从反序列化EmbeddedWrapper类.
使用Angular CLI 1.0(来自beta.31)将我的项目升级到Angular 4.0(从2.4),按照迁移指南后我得到以下错误:
> ng build --prod
The "@angular/compiler-cli" package was not properly installed.
Error: The "@angular/compiler-cli" package was not properly installed.
at Object.<anonymous> (/home/jan/src/fm-repos/fm-ui/node_modules/@ngtools/webpack/src/index.js:14:11)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/home/jan/src/fm-repos/fm-ui/node_modules/@angular/cli/tasks/eject.js:10:19)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
Run Code Online (Sandbox Code Playgroud)
迁移后我的角度依赖关系:
"@angular/animations": "^4.0.0", …Run Code Online (Sandbox Code Playgroud) 我想index.html从一个Angular 2项目中运行一个Spring MVC应用程序的欢迎页面.我们不能使用maven项目,只需创建spring MVC项目.
我已经尝试将angular dist文件夹复制到web目录中,
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
Run Code Online (Sandbox Code Playgroud)
这是我的文件夹结构,
我得到HTTP状态404 -Error
任何只能帮助我
提前致谢!!!
我猜这更像是一个普通的Java/Eclipse问题,但我不是一个Java人,这不是为了点击我.最后堆栈跟踪.
上面是抛出错误的文件,它非常简单 - 我们是否使用URLClassLoader?不是一个Java人,我不明白如何切换到URLClassLoader谷歌搜索这让我觉得这不是我需要关注的事情.
"Unable to use ClassLoader to detect classpath elements"
Run Code Online (Sandbox Code Playgroud)
让我觉得我错误地添加了一个类路径,Eclipse正在做一些奇怪的事情.
Google dataflow/apache beam文档都没有提到任何关于a的内容URLClassLoader,现在我甚至无法让他们的示例项目运行.我很确定我做了什么,但我不确定是什么.
任何帮助,将不胜感激.
Jan 16, 2018 8:03:48 PM org.apache.beam.runners.dataflow.DataflowRunner
detectClassPathResourcesToStage
SEVERE: Unable to use ClassLoader to detect classpath elements. Current ClassLoader is jdk.internal.loader.ClassLoaders$AppClassLoader@3b764bce, only URLClassLoaders are supported.
Exception in thread "main" java.lang.RuntimeException: Failed to construct instance from factory method DataflowRunner#fromOptions(interface org.apache.beam.sdk.options.PipelineOptions)
at org.apache.beam.sdk.util.InstanceBuilder.buildFromMethod(InstanceBuilder.java:233)
at org.apache.beam.sdk.util.InstanceBuilder.build(InstanceBuilder.java:162)
at org.apache.beam.sdk.PipelineRunner.fromOptions(PipelineRunner.java:52)
at org.apache.beam.sdk.Pipeline.create(Pipeline.java:142)
at twitchInsights.MainPipeline.main(MainPipeline.java:59)
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) …Run Code Online (Sandbox Code Playgroud) 我刚刚ng upgrade为我的Angular 6应用程序做了一个,现在我得到了:
ERROR in node_modules/@angular/flex-layout/core/typings/observable-media/observable-media.d.ts(11,14): error TS2416: Property 'subscribe' in type 'ObservableMedia' is not assignable to the same property in base type 'Subscribable<MediaChange>'.
Type '(next?: (value: MediaChange) => void, error?: (error: any) => void, complete?: () => void) => Sub...' is not assignable to type '{ (observer?: PartialObserver<MediaChange>): Unsubscribable; (next?: (value: MediaChange) => void...'.
Types of parameters 'next' and 'observer' are incompatible.
Type 'PartialObserver<MediaChange>' is not assignable to type '(value: MediaChange) => void'.
Type 'NextObserver<MediaChange>' is not …Run Code Online (Sandbox Code Playgroud) 在STS 4中,我的Java 10 Spring Boot 2.1项目警告我:
未知的引用性质:org.springframework.ide.eclipse.core.springnature
我怎样才能解决这个问题?
我的Angular 2应用程序使用默认的HTML 5 history.pushState 位置策略.如何使用history.pushState浏览器刷新配置服务器并且浏览器URL不生成404s?
例如,Tour of Heroes应用程序有一些不同的应用程序路径,例如:
http://localhost:8080/dashboard
http://localhost:8080/heroes
http://localhost:8080/detail/13
Run Code Online (Sandbox Code Playgroud)
如果你打刷新在这些航线上的一个,或键入一个URL,你会得到404,因为/detail/13是一个应用程序的路线,而不是服务器资源.我已将位置策略配置head在我的顶部index.html:
<!doctype html>
<html>
<head>
<base href="/">
<meta charset="utf-8">
<title>Tour of Heroes</title>
Run Code Online (Sandbox Code Playgroud)
但是如何配置服务器以便将所有URL发送到我的应用程序而不是生成404?
注意:这个问题是问题的补充当我通过浏览器刷新Angular 2:404错误时,Angular 2.0路由器无法重新加载浏览器,询问如何解决此问题.对于Firebase,有这样的:当我刷新我的网站时,我得到一个404.这是使用Angular2和firebase,对于Apache,这就是:Angular路由的htaccess重定向.
如何为Java Project Reactor反应FluxAPI 创建Angular 4客户端?下面的示例有两个API:MonoAPI; 和,FluxAPI.两者都起作用curl; 但在Angular 4(4.1.2)中,只有MonoAPI有效; 任何想法如何让Angular 4与FluxAPI 一起工作?
这是一个简单的Spring Boot 2.0.0-SNAPSHOT应用程序,它带有MonoAPI和FluxAPI:
@SpringBootApplication
@RestController
public class ReactiveServiceApplication {
@CrossOrigin
@GetMapping("/events/{id}")
public Mono<Event> eventById(@PathVariable long id) {
return Mono.just(new Event(id, LocalDate.now()));
}
@CrossOrigin
@GetMapping(value = "/events", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
public Flux<Event> events() {
Flux<Event> eventFlux = Flux.fromStream(
Stream.generate(
()->new Event(System.currentTimeMillis(), LocalDate.now()))
);
Flux<Long> durationFlux = Flux.interval(Duration.ofSeconds(1));
return Flux.zip(eventFlux, durationFlux).map(Tuple2::getT1);
}
public static …Run Code Online (Sandbox Code Playgroud) 我刚刚将Spring Boot 1.5.13应用程序(使用Lombok)升级到Spring Boot 1.5.14,但现在无法使用以下类型的错误进行编译:
constructor SomeClass() is already defined in class SomeClass
Run Code Online (Sandbox Code Playgroud)
对于我的每个POJO,例如,
@Data
@NoArgsConstructor
public class SomeClass {
private String someProperty;
}
Run Code Online (Sandbox Code Playgroud) angular ×5
java ×3
spring-boot ×2
spring-mvc ×2
angular-cli ×1
angular-http ×1
angular2-cli ×1
lombok ×1
rest ×1
rxjs5 ×1
spring ×1
spring-4 ×1
spring-data ×1
tomcat7 ×1