我已使用 ElasticBeanstalk 在 AWS 上创建了一个预配置的 node.js 实例,但该应用程序无法正常运行。所以我连接到实例并发现没有节点或角度cli,所以我手动安装了它们。然后我尝试在应用程序文件夹中运行 npm install 但失败,这是输出错误。
[ec2-user@ip current]$ npm install
npm WARN checkPermissions Missing write access to /var/app/current/node_modules/tslib
npm WARN checkPermissions Missing write access to /var/app/current/node_modules/@ngx-loading-bar/core
npm WARN checkPermissions Missing write access to /var/app/current/node_modules/@angular/animations
npm WARN checkPermissions Missing write access to /var/app/current/node_modules/@angular/common
npm WARN checkPermissions Missing write access to /var/app/current/node_modules/@angular/compiler
npm WARN checkPermissions Missing write access to /var/app/current/node_modules/@angular/core
npm WARN checkPermissions Missing write access to /var/app/current/node_modules/@angular/forms
npm WARN checkPermissions Missing write access to /var/app/current/node_modules/@angular/http
npm WARN …
Run Code Online (Sandbox Code Playgroud) 下面是我的控制台日志:
jy03154586@ubuntu:~/Works$ docker build -t ui .
Sending build context to Docker daemon 50.18MB
Step 1/9 : FROM node:carbon-alpine as build
---> adc4b0f5bc53
...
Step 9/9 : COPY --from=build /app/dist /usr/share/nginx/html
---> 997cc6252b83
Successfully built 997cc6252b83
Successfully tagged ui:latest
jy03154586@ubuntu:~/Works$ docker images ls
REPOSITORY TAG IMAGE ID CREATED SIZE
jy03154586@ubuntu:~/Works$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
jy03154586@ubuntu:~/Works$
Run Code Online (Sandbox Code Playgroud)
我尝试构建一个 angularjs 应用程序镜像,但是构建的镜像在哪里?表明successfully built
我想显示LocalDate
为:
first day: 1st;
second day: 2nd;
third day: 3rd;
all rest days: Nth.
Run Code Online (Sandbox Code Playgroud)
例如1980-10-1
作为1st Oct 1980
我可以使用 对其进行序列化,不包括前 3 天DateTimeFormatter.ofPattern("dth MMM yyyy")
。由于前 3 天与其余日期的模式不同,如何构建格式化程序来序列化前 3 天?
我有一个 HotelRepository,它有一个命名方法,它返回一个默认Page<Hotel>
项作为结果而不是一个列表。
我想将内容类型更改Hotel
为HotelDto
在页面中,因为 DTO 具有我想要显示的自定义参数。我已经有一个构造函数可以将 Hotel 转换为 HotelDto。
我的尝试:
Page<Hotel> hotels = dao.findAll(pageRequest);
return new PageImpl<>(
hotels.getContent().stream()
.map(hotel -> new HotelListItemDto(hotel, hotel.getSupplier())).collect(Collectors.toList()),
pageRequest, hotels.getContent().size());
Run Code Online (Sandbox Code Playgroud)
问题是它只操作结果的一页。当然,我可以先把所有的结果作为一个列表,然后根据列表创建一个页面,但是这样就失去了Page
(我认为返回页面会提高搜索请求的性能)的优势。
那么我应该怎么做才能保持页面优势,但仍然可以自定义输出?
docker-compose.yml:
services:
server:
image: server:latest
environment:
- SPRING_PROFILES_ACTIVE=dev
ports:
- 8080:8080
- 18080:18080
Run Code Online (Sandbox Code Playgroud)
Dockerfile:
FROM openjdk:8-jre-alpine
ENV SPRING_OUTPUT_ANSI_ENABLED=ALWAYS \
SLEEP=0 \
JAVA_OPTS="" \
RUN adduser -D -s /bin/sh server
WORKDIR /home/server
ADD entrypoint.sh entrypoint.sh
RUN chmod 755 entrypoint.sh && chown server:server entrypoint.sh
USER server
ENTRYPOINT ["./entrypoint.sh"]
# expose server ports
EXPOSE 8080 18080
ADD *.jar server.jar
Run Code Online (Sandbox Code Playgroud)
入口点.sh:
#!/bin/sh
echo "The application will start in ${SLEEP}s..." && sleep ${SLEEP}
exec java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar "${HOME}/server.jar" "$@"
Run Code Online (Sandbox Code Playgroud)
我有 3 个 application.yml: application.yml …
假设我有
class A {};
template<typename T, typename U> class Wrapper {};
Run Code Online (Sandbox Code Playgroud)
我正在尝试检查包装器的第一个内部类型是否为A
.
typeCheck(new A(), new Wrapper<A,B>); // expect true
typeCheck(new A(), new Wrapper<C,B>); // expect false
Run Code Online (Sandbox Code Playgroud)
最好的方法是什么?
我尝试过模板部分专业化,但没有运气。
这是我尝试过的代码:
template<typename T> struct get_inner {
using type = T;
}
template<typename T, typename U>
struct get_inner<Wrapper<T,U>> {
using type = T;
}
std::cout<< typeid(get_inner<decltype(new Wrapper<A,B>)>::type);
Run Code Online (Sandbox Code Playgroud)
控制台显示相同的包装类型而不是内部类型A
。这里有什么错误吗?
从spring boot文档中,@ConfigurationProperties
将
从带@ConfigurationProperties注释的项目生成您自己的配置元数据文件
我尝试在配置类上单独使用use @Configuration
和@ConfigurationProperties
。
@Component
//@Configuration
@ConfigurationProperties
@EnableSpringDataWebSupport
@EnableAsync
public class AppConfig {
...
}
Run Code Online (Sandbox Code Playgroud)
我没有发现任何明显的差异。
@ConfigurationProperties
或的用途是@Configuration
什么?
我正在尝试在WebClient
没有请求正文的情况下对 api 进行 POST 调用(该 api 不需要正文):
webClient.post()\n .uri("url")\n .retrieve()\n .bodyToMono(CustomResponse.class);\n
Run Code Online (Sandbox Code Playgroud)\n\n但调用返回异常:
\n\n\n\n\n底层 HTTP 客户端已完成,\n 未发出响应。java.lang.IllegalStateException: 底层 HTTP 客户端已完成,\n 未发出响应。
\n
对于另一个需要请求正文的 API,我可以成功地进行 POST 调用,没有任何问题:
\n\nwebClient.post()\n .uri("url")\n .bodyValue("value")\n .retrieve()\n .bodyToMono(CustomResponse.class);\n
Run Code Online (Sandbox Code Playgroud)\n\n问题是否与 WebClient\xe2\x80\x99s 请求正文有关?我如何解决它?
\n\n更新
\n\n发生错误的原因是我ContentType
通过 添加了 Webclient 的标头.defaultHeader("ContentType", JSON)
。\n删除标头后问题就消失了。
class Person {
private List<Phone> phones;
}
class Phone {
private String number;
}
assertThat(result).usingRecursiveComparison()
.ignoringCollectionOrder()
.isEqualTo(expectedPerson);
Run Code Online (Sandbox Code Playgroud)
具有expectedPerson
相同数量的电话和电话号码,但测试失败,因为列表引用不同。如果我没记错的话,usingRecursiveComparison
只会比较价值。那么为什么这里失败了呢?
public class Hotel{
@ManyToOne(optional = false)
@NotNull
@JoinColumn(name = "hotel_city", referencedColumnName = "city_id")
private City city;
}
public class City{
@Column(name = "public_id", updatable = false, unique = true)
@NotEmpty
private String publicId;
}
Run Code Online (Sandbox Code Playgroud)
我想找到城市的 publicId 等于给定字符串的所有酒店。
public Predicate toPredicate(Root<Hotel> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
Subquery<City> subquery = query.subquery(City.class);
Root<City> subRoot = subquery.from(City.class);
Predicate cityIdPredicate = cb.equal(subRoot.get("publicId"), criteria.getValue().toString());
return cb.equal(root.get("city"), cityIdPredicate);
}
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用上面的代码
好像出问题了。这是我第一次使用规范,任何提示都是有帮助的。谢谢。
java ×5
spring-boot ×4
docker ×2
assertj ×1
c++ ×1
junit5 ×1
node.js ×1
pagination ×1
spring ×1
templates ×1
thymeleaf ×1
type-traits ×1
typechecking ×1
unit-testing ×1