我有一个存储库接口,如下所示:
public interface ExcursionAttendeeRepository extends MongoRepository<ExcursionAttendee, String> {
ExcursionAttendee findByWorkflowItemId(String workflowItemId);
@Query("{ 'excursionEvent._id' : { '$oid' : ?0 } }")
List<ExcursionAttendee> findByExcursionId(String excursionId);
@Query("{ 'student._id' : {'$oid' : ?0} , 'excursionEvent._id' : { '$oid' : ?1 } }")
ExcursionAttendee findByStudentIdAndEventId(String studentId, String excursionId);
@Query("{ 'student._id' : { '$oid' : ?0 } }")
List<ExcursionAttendee> findByStudentId(String studentId);
}
Run Code Online (Sandbox Code Playgroud)
而Bean创建spring则抛出异常.
Context initialization failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer#0.1':
Cannot create inner bean '(inner bean)#5172829b' of type [org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter] while setting bean property …Run Code Online (Sandbox Code Playgroud) 经过数周的努力,我发布了这个帖子.我尝试尝试,因为我感到内疚,因为有类似于此的线程.但是我的错误仍然略有不同.所以我所拥有的是一个非常简单的弹簧(当然不需要弹簧bcz问题是maven)应用程序与maven.
这是我的pom的插件部分.
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<url>http://localhost:8080/manager</url>
<username>tomcat</username>
<password>s3cret</password>
<path>/Test</path>
<port>8080</port>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
Run Code Online (Sandbox Code Playgroud)
早些时候我有maven tomcat插件无法使用tomcat 7等问题,但现在用"tomcat7-maven-plugin"解决了.我正在使用' http://localhost:8080/manager'作为URL.对于这个maven tomcat编译器插件的几乎所有线程都是关于构建失败的.但我的构建成功(我运行tomcat7:deploy).问题是tomcat正在回复
tomcatManager状态码:403,ReasonPhrase:Forbidden
以及我们在浏览器上遇到身份验证失败时看到的html.在我的Linux机器下,相同的代码工作正常.我尝试在settings.xml中使用server元素的不同场景,它位于.m2内部和maven_home/conf等内部.仍然无效.
正如我弄清楚maven无法验证tomcat.找到用户名和密码,我可以使用GUI登录.所以期待在这里提供帮助.
ps - 我的tomcat-users.xml fiel
<role rolename="manager-gui" />
<user username="tomcat" password="s3cret" roles="manager-gui"/>
Run Code Online (Sandbox Code Playgroud) 我可以使用SimpMessagingTemplate#convertAndSendToUser或SimpMessagingTemplate#convertAndSend方法向消息代理发送消息,而无需设置websocket消息代理@EnableWebSocketMessageBroker吗?
我要做的是利用一个websocket服务器为两个应用服务器实例提供消息(一个春天4和一个春天3).我创建了一个带有Spring 4,Spring启动和websocket消息代理的Web服务器.
现在我想要两个应用程序服务器将消息推送到rabbitmq,以便它们将它们广播给订阅它的客户端.
我面临的第一个问题是,如果没有可用的websockt消息代理配置,SimpMessagingTemplate则不会自动连接到应用程序上下文.如果没有创建websocket留言板,我无法注入它.
请帮我弄清楚这是否可行.
我想加密一个包含少量String的结构,然后解密它.我试过以下代码.原始代码可以从网上找到,并且工作正常.我将它的输入更改为结构.以下是代码.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <openssl/aes.h>
#include <openssl/rand.h>
typedef struct ticket { /* test field */
int ticketId;
char username[20];
char date[20];
} USR_TICKET;
// a simple hex-print routine. could be modified to print 16 bytes-per-line
static void hex_print(const void* pv, size_t len)
{
const unsigned char * p = (const unsigned char*)pv;
if (NULL == pv)
printf("NULL");
else
{
size_t i = 0;
for (; i<len;++i)
printf("%02X ", *p++);
}
printf("\n");
}
// main …Run Code Online (Sandbox Code Playgroud) 以下是请求fullcalendar js发送到服务器.
http://localhost:8080/NVB/rest/calendar/events?start=1425168000&end=1428796800 400
Run Code Online (Sandbox Code Playgroud)
如何@DateTimeFormat在Spring Request Param中指定Date pattern()以将此时间转换为Date对象.我尝试了不同的模式,但得到了405 Bad Request.
@RequestMapping(value = "/events", method = RequestMethod.GET)
public @ResponseBody List<EventDto> addOrder(@RequestParam(value = "start") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Date start,
@RequestParam(value = "end") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Date end) {
LOGGER.info("Requesting event from [{}] to [{}]", start, end);
return new LinkedList<EventDto>();
}
Run Code Online (Sandbox Code Playgroud) 我有一个使用Slf4j和java.util.Logging设置的日志记录机制.我有几个线程,所以我无法从日志中得到一个清晰的想法,因为它们是混合的.现在我尝试使用MDC概念在日志文件中添加更多数据,以便它们清晰.
问题与Slf4j中的一样,虽然它支持MDC java.util.Logging不支持.但它说
如果底层框架不提供MDC,例如java.util.logging,则SLF4J仍将存储MDC数据,但其中的信息需要由自定义用户代码检索.
我正在尝试找到一种方法来执行此自定义代码.谷歌搜索对我没什么帮助.Slf4j中有一个名为"BasicMDCAdapter"的辅助类.但我不知道如何使用它.我无法在任何地方找到示例代码.
这也是一个有助于此的代码,但仍然没有给出一些描述.
我很感激这里的帮助.
谢谢.
我有一个Student对象扩展Person对象.
public abstract class Person implements IIdentifiable {
private String contactNumber;
// other properties
public String getContactNumber() {
return contactNumber;
}
public void setContactNumber(String contactNumber) {
this.contactNumber = contactNumber;
}
}
public class Student extends Person {
private String studentNumber;
//Other properties
public String getStudentNumber() {
return studentNumber;
}
public void setStudentNumber(String studentNumber) {
this.studentNumber = studentNumber;
}
}
Run Code Online (Sandbox Code Playgroud)
学生有财产studentNumber,人有财产contactNumber.当我将Student对象映射到StudentDto它时,会对给定的属性感到困惑.
public class StudentDto{
private String studentNumber;
public String getStudentNumber() { …Run Code Online (Sandbox Code Playgroud) myFunc可以采用string或number但由于参数被定义为 T 在传递字符串时给出错误。
interface Props<T> {
items: T[],
onValueChange: (vals: T[]) => void;
}
export const myComponent = <T extends string | number>(props: Props<T>) => {
const {
items = [],
onValueChange
} = props;
const myFunc = (item: T) => {
//do something
console.log(item);
onValueChange([item])
}
items.map(item => myFunc(item));
myFunc('test');
}
Run Code Online (Sandbox Code Playgroud)
错误
Argument of type 'string' is not assignable to parameter of type 'T'.
'string' is assignable to the constraint of type 'T', but …Run Code Online (Sandbox Code Playgroud) 我正在 js 中为 mono 仓库编写 bazel 规则。这背后的想法是 Mono 存储库(微服务)内的服务在开放的 api 模式文件中定义 api 规范。在我们的例子中,这些模式位于 ts 文件中,因为当每个路由和最终规范文件导入每个路由模式并集成到最终对象时,规范被破坏。
我想在集中位置编写 bazel 规则,以便每个项目都可以加载该规则并使用其架构文件调用它
generate_yaml_from_ts(
name = 'generate_yaml',
schema = "src/api/routes/openapi.schema.ts"
)
Run Code Online (Sandbox Code Playgroud)
我不确定是否所有模式文件( openapi.schema.ts 导入其他 ts 文件)都需要可供规则使用。
在规则中,我有一个 ts 代码,我想在其中引用传递的模式文件并生成yaml文件。(如下所示,我知道静态导入不起作用)
import fs from 'fs';
import YAML from 'yaml';
import openapiJson from './src/api/routes/openapi.schema';
fs.writeFileSync(process.argv[2], YAML.stringify(openapiJson));
Run Code Online (Sandbox Code Playgroud)
我创建了一个节点可执行文件以从代码运行ts-node,但问题是我们提供的输入也是ts文件,因此需要首先编译。
我可以想到两种可能的方法来解决这个问题,但我不确定到底该怎么做。
ts在从服务传递到规则之前编译架构。(使用 ats_library并将输出传递给规则?)ts-node在 bzl 文件中使用),传递源文件连接generateYml.ts和传递的模式文件。github上提供了带有 bazel 设置的简单项目
我编写了一条规则,从项目中获取 json 文件并生成build/rules/json2yaml有效的 yaml。 …
我一直在尝试使用Spring安全性来学习不同的东西.我设置了具有"用户"表和"权限"表的基本结构的授权.所以我的身份验证提供程序如下所示.
<authentication-provider>
<password-encoder hash='md5'>
<salt-source user-property="username"/>
</password-encoder>
<jdbc-user-service data-source-ref="dataSource"/>
</authentication-provider>
Run Code Online (Sandbox Code Playgroud)
这样我就不会指定查询来获取用户详细信息,因为我使用的是默认数据库模式.因此,尽管我没有使用"权限由用户名 - 查询"属性,Spring正在使用默认查询("选择用户名,权限来自权限用户=?"和"选择用户名,密码,从用户名=? ")所以事情进展顺利.
现在我想尝试权限组.所以我根据架构创建表.我的问题如何激活群组权限?JdbcDaoImpl的API文档说使用"enableGroups"属性来启用"基于组的权限".但"基于团体的当局"没有这样的财产.由于Spring有默认查询,我认为不需要明确给出它.
因此,有人可以帮我在这里使用默认查询启用基于组的权限.
我正在使用 Spring Caching 框架和 redis。以下是我使用的 Cacheable
@Cacheable(value = "oauth2token", key="#value + #type")
public OAuth2Token findOneByValueAndType(String value, String type);
Run Code Online (Sandbox Code Playgroud)
我只是想创建一个我知道的密钥。这给出了错误
14:20:21,199 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/veip-web].[Resteasy]] (http-/0.0.0.0:8080-63) JBWEB000236: Servlet.service() for servlet Resteasy threw exception: org.springframework.expression.spel.SpelEvaluationException: EL1030E:(pos 0): The operator 'ADD' is not supported between objects of type 'null' and 'null'
Run Code Online (Sandbox Code Playgroud)
因为当我没有将 key 指定为流时。
@Cacheable(value = "oauth2token")
public OAuth2Token findOneByValueAndType(String value, String type);
Run Code Online (Sandbox Code Playgroud)
我可以看到生成了一个疯狂的密钥。我需要知道密钥,因为稍后我需要CachePut更新相同的项目。
我也尝试跟随。
@Cacheable(value = "oauth2token", key="#type.contact(#value)")
public OAuth2Token findOneByValueAndType(String value, String type);
Run Code Online (Sandbox Code Playgroud)
Spring 抱怨那个时候#type是空的。
这里有什么问题。
spring-mvc ×3
java ×2
spring ×2
aes ×1
bazel ×1
bazel-rules ×1
c ×1
cryptography ×1
datetime ×1
encryption ×1
login ×1
maven ×1
mdc ×1
modelmapper ×1
mongodb ×1
openssl ×1
slf4j ×1
spring-4 ×1
spring-cache ×1
spring-data ×1
spring-el ×1
tomcat7 ×1
typescript ×1