我有一个REST调用接受一个JSON对象,比方说,一个人.在我创建此对象(验证并保存到数据库)后,我需要返回新创建的JSON对象.
我认为标准做法是返回201 Accepted而不是立即返回对象.但我的应用程序需要立即新创建的对象.
我有一个控制器方法,它接受一个POST调用,调用一个服务类,然后调用一个使用Hibernate来创建对象的DAO.一旦它保存到数据库,我正在调用另一个控制器方法,该方法获取人员的ID并返回对象.
我的问题是,这是更好的方法吗?这是调用另一个Controller方法来获取新创建的对象.或者POST调用本身应该返回Object.
主要问题是: 调用另一种方法需要往返,我猜这是一种矫枉过正.(服务- > DAO-> Hibernate->数据库).相反,我认为我应该在相同的调用(从处理POST的方法)中保存后立即从数据库中获取对象.
这里的架构标准是什么?
我有一个带有 application.yml 的 Spring Boot 应用程序。
application.yml的内容:
spring:
profiles:
active: default,private
integrations:
ecom:
api-url: http://localhost:8080/com
Run Code Online (Sandbox Code Playgroud)
application-private.yml 的内容:
integrations:
ecom:
api-url: http://testenv:8080/com
Run Code Online (Sandbox Code Playgroud)
根据我的理解,集成:ecom:api-url 正在从 application-private.yml 加载,即使默认配置文件也具有相同的属性。
如果两个配置文件处于活动状态,是否会按照指定配置文件的顺序加载和使用该属性?
我的订单:
-Dspring.profiles.active="default,private"
Run Code Online (Sandbox Code Playgroud)
提前致谢。
我已经配置了如下的logstash配置来读取spring boot生成的日志以推送到弹性搜索中,但是即使logstash成功启动,索引也没有创建,
配置文件:
input {
file {
path => "C:\workspace\app\logback\applogs.log"
codec => "json"
type => "logback"
}
}
output {
if [type]=="logback" {
elasticsearch {
hosts => [ "localhost:9200" ]
index => "logback-test"
}
}
}
Run Code Online (Sandbox Code Playgroud)
提前致谢!
我正在运行以下查询.它显示错误消息.如何解决这个错误?
List<Route>routeList=null;
List<?> companyList = session.createSQLQuery ("select name " +
"from company "+
"where company_id= " + companyId).list();
if(companyList.size() <= 0){
//throw(new AppException(1018,ErrorMessages.getString("INVALID_USER_ID")));
}
routeList = new ArrayList<Route>(companyList.size());
Route vgDetails=null;
for (int i = 0; i < companyList.size(); i++) {
vgDetails = new Route();
Object[] row = (Object[])companyList.get(i);
vgDetails.setRouteName ((String)row[0]);
routeList.add(vgDetails);
}
session.getTransaction().commit();
return routeList;
}
Run Code Online (Sandbox Code Playgroud)
错误是:
java.lang.ClassCastException: java.lang.String cannot be cast to [Ljava.lang.Object;
at com.claystone.server.user.UserListServiceImpl.getParticipantsDestination(UserListServiceImpl.java:902)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:527) …Run Code Online (Sandbox Code Playgroud) 有没有人用过Kotlin的招摇工具?
在我们的组织中,我们使用Java和SpringMVC(@RestController类)创建了大部分REST服务.我们使用springfox生成Swagger API文档.swagger JSON表示也用于自动提供可搜索的服务目录,因此服务元数据的swagger格式对我们很重要.
一些开发团队现在开始使用Kotlin.我们正在寻找有关使用springfox或其他swagger lib与Kotlin相关的建议或意见.
在基于Docker映像的OpenShift上创建新应用程序的语法有点混乱:
Usage:
oc new-app (IMAGE | IMAGESTREAM | TEMPLATE | PATH | URL ...) [options]
. . .
Options:
. . .
--docker-image=[]: Name of a Docker image to include in the app.
. . .
Run Code Online (Sandbox Code Playgroud)
指定docker映像作为IMAGE参数与在--docker-image选项中指示映像之间有什么区别?
假设我的映像位于docker hub(docker.io)中,它是myid/myrepo:latest。下面的命令是否是创建应用程序的正确方法?
oc new-app myid/myrepo:latest --docker-image="docker.io/myid/myrepo:latest"
Run Code Online (Sandbox Code Playgroud)
我正在使用OpenShift v1.3.0。
Logstashkv过滤器不包含带空格的值。请检查下面 Logstash 生成的输入和输出消息。所需的输出应包含空格。
输入消息:
key1=first value key2=second value key3=value3
Run Code Online (Sandbox Code Playgroud)
期望的输出:
{
"key1" => "first value",
"key2" => "second value",
"key3" => "value3",
"message" => "key1=first value key2=second value key3=value3"
}
Run Code Online (Sandbox Code Playgroud)
获得的输出:
{
"key1" => "first",
"key2" => "second",
"key3" => "value3",
"message" => "key1=first value key2=second value key3=value3"
}
Run Code Online (Sandbox Code Playgroud)
我需要将值中的空格包含在字段中。如何在 Logstash 中执行此操作?
我是 Spring 批处理的新手。我创建了一个决策程序,它将 FlowExecutionStatus 返回为“YES”/“NO”。基于FlowExecutionStatus,我需要调用step2()或step3()。
在我下面的代码中,step2()在决策程序之前被调用。如何修改代码以便调用决策程序,并根据FlowExecutionStatus返回的 bu调用step2()或step3()应该调用决策程序。请帮忙。
@Autowired
private NumberDecider decider;
@Bean
public Job NumberLoaderJob() throws NumberFormatException, IOException {
return jobBuilderFactory.get("numberLoaderJob").start(step1()).listener(new MyNumberJobListener())
.next(decider).on("YES").to(step2())
.from(decider).on("NO").to(step3()).end().build();
}
@Bean
public Step step1() {
return stepBuilderFactory.get("step1").tasklet(new Tasklet() {
@Override
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
System.out.println("Exiting step1() execute()");
return RepeatStatus.FINISHED;
}
}).build();
}
/**
* Step 2
*
* @return
* @throws NumberFormatException
* @throws IOException
*/ …Run Code Online (Sandbox Code Playgroud) java ×2
logstash ×2
spring-boot ×2
hibernate ×1
json ×1
kibana ×1
kotlin ×1
openshift ×1
rest ×1
spring ×1
spring-batch ×1
spring-mvc ×1
standards ×1
swagger ×1