我想调整我的代码,使其Spring Batch reader不是从类路径读取资源文件,而是从文件系统(如C:\ inputData.xml)读取资源文件.有什么办法,怎么做?我当前的代码看起来像这样,并xml从资源文件夹中读取给定的文件就好了:
@Bean
ItemReader<FamilyBatchEntity> xmlFamilyFileItemReader() {
StaxEventItemReader<FamilyBatchEntity> xmlFileReader = new StaxEventItemReader<>();
xmlFileReader.setResource(new ClassPathResource("inputData.xml"));
xmlFileReader.setFragmentRootElementName("Familiendetails");
Jaxb2Marshaller insurantMarshaller = new Jaxb2Marshaller();
insurantMarshaller.setClassesToBeBound(FamilyBatchEntity.class);
xmlFileReader.setUnmarshaller(insurantMarshaller);
return xmlFileReader;
}
Run Code Online (Sandbox Code Playgroud) 我想迭代一个stirngs向量,并将所有输入与值进行比较.所以我创建了这个结构:
for (vector<string>::const_iterator i = needle.begin(); i != needle.end(); ++i) {
cout << *i << " ";
}
Run Code Online (Sandbox Code Playgroud)
打印工作正常,但我希望能够访问std::string函数,即find
所以当我能够编写时,needle[index].find("sampleString");我希望能够使迭代器的行为与此类似.那么如何做出类似的东西*i.find("sampleString");呢?
我有mutlithread通过通信的客户端 - 服务器应用程序sockets.我使用这种结构创建新线程:
pthread_t thread;
pthread_create(&thread, NULL, c->sendMessage, (void *) fd);
Run Code Online (Sandbox Code Playgroud)
其中fd是连接的ID,c->sendMessage是一个函数,在创建新线程并处理该线程后调用.在这个函数中,我需要通过发送一些消息send(int sockfd, const void *buf, size_t len, int flags);
所以我sockfd这样说:
void * Client::sendMessage(void *threadid) {
int sockfd = (int) threadid;
// some more code here and in the end I send the data via send(int sockfd, const void *buf, size_t len, int flags)
}
Run Code Online (Sandbox Code Playgroud)
我使用-pedanticflag 编译,大多数编译器(包括我的编译器)在编译期间不会抛出任何警告或错误.但一些编译说,从这个重复输入过程中抛出一个错误void *来int是不安全的,可能会导致loose of precision.我明白,这不是一个好的解决方案,应该做得更清洁.但我无法弄清楚如何.任何人都可以建议我任何干净的练习,如何重新输入ponter到int并避免编译期间的任何警告?
我已经创建了MVC模板Spring Tool Suite IDE,但我无法实现,如何从中获取值jsp.为了exmaple - 我已经创建了文本输入jsp
<input type="text" />
Run Code Online (Sandbox Code Playgroud)
但如何获得控制器的价值,以便能够在那里工作?我知道,当我在控制器中为模型添加属性时,我可以通过它访问它${name},但是如何以其他方式执行它?
我在为我的CMatrix类中的const实例定义重载的operator +时遇到了麻烦.我有这个定义为 + operator尚未
CMatrix operator+(const CMatrix &matrix) const;
它适用于non-constCMatrix的实例.但我做不到这样的事情:
const CMatrix a;
const CMatrix b;
const CMatrix c;
a=b+c;
Run Code Online (Sandbox Code Playgroud)
我在尝试编译源代码时遇到此错误: error: passing ‘const CMatrix’ as ‘this’ argument of ‘CMatrix& CMatrix::operator=(const CMatrix&)’ discards qualifiers
任何人都可以告诉我,如何定义重载以便+ operator能够编译代码?
我正在创建一个类似客户端 - 服务器聊天的应用程序C++,我正在做UI ncurses.我想存储所有消息,vector<char *> msgVector以便能够定期重绘整个屏幕.然而,当我想打印出值时,所有项目都具有相同的值 - 最后接受的消息.
void acceptMessages() {
char buffer[256];
fd = c->createClient2Fd("localhost", 12345);
while (true) {
memset(buffer, 0, sizeof ( buffer));
int l = recv(fd, buffer, sizeof ( buffer), 0);
msgVector.push_back(buffer);
redrawScreen();
}
void redrawScreen() {
erase();
mvhline(0, 0, ACS_HLINE, COLS);
mvhline(LINES - 2, 0, ACS_HLINE, COLS);
mvaddstr(LINES - 1, 0, "MESSAGE:");
move(LINES - 1, 9);
// prints right count of messages
// but on every line is printed only the …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建简单的项目来学习C++中的头文件和继承.我创建了头文件:
Bot.h
#include <vector>
#include <string>
#include <cstdlib>
using namespace std;
class Bot {
public:
Bot();
~Bot();
bool initialized;
string getRandomMessage();
string getName();
protected:
vector<string> messages;
string name;
};
Run Code Online (Sandbox Code Playgroud)
然后我就Bot.cpp到了
/**
*
* @return random message from Bot as string
*/
string Bot::getRandomMessage() {
int r = static_cast<double> (std::rand()) / RAND_MAX * this->messages.size();
return messages[r];
}
/**
*
* @return bot's name as string
*/
string Bot::getName() {
return this->name;
}
Run Code Online (Sandbox Code Playgroud)
而现在我无法弄清楚,如何分割成header和cpp文件以及如何处理包含和其他东西以使它在我继承的类中都能正常工作,我已经实现了这样:
/**
* Specialized bot, that hates …Run Code Online (Sandbox Code Playgroud) 我有一个spring boot应用程序,用于JPA访问数据库中的数据。现在我需要执行更复杂的查询,但我不知道如何进行。
在我的存储库界面中,我有一个工作查询,它通过用户名选择用户的所有聊天线程:
@Query("SELECT chatThread FROM ChatThread chatThread WHERE (chatThread.userId) = (:id)")
public List<ChatThread> find(@Param("id") String id);
Run Code Online (Sandbox Code Playgroud)
但现在如何调整它,只选择尚未阅读的消息呢?存在一个hibernate OneToMany relationship并且该方案看起来像这样:

c++ ×5
java ×3
spring ×2
classpath ×1
compilation ×1
gcc ×1
header ×1
hibernate ×1
inheritance ×1
iterator ×1
jpa ×1
jsp ×1
ncurses ×1
sockets ×1
spring-batch ×1
spring-mvc ×1
sql ×1
vector ×1