我的 Mapper 有问题。我正在使用 mapstruct-processor 来构建 Maven 项目。我一直收到警告:警告:(15, 16)java:未映射的目标属性:“从,到”。警告:(13, 13) java:未映射的目标属性:“clientFrom,clientTo”。我想用它做什么?类 Client 运行良好并创建了一个客户端。
@Entity
public class Message {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String message;
@ManyToOne(cascade = {CascadeType.ALL})
@JoinColumn(name = "client_from")
private Client clientFrom;
@ManyToOne
@JoinColumn(name = "client_to")
private Client clientTo;
public Message(){}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public Client getClientFrom() …Run Code Online (Sandbox Code Playgroud) 我试图用逗号分割字符串.但它没有像预期的那样表现
var classes = "10,7,8,9";
Console.Write(string.Join(",", classes.Split(',').OrderBy(x => x)));
Console.ReadKey();
Run Code Online (Sandbox Code Playgroud)
和输出是
10,7,8,9
但我希望预期的输出如下:
7,8,9,10
类可以包含一个部分.像7a,7b
我想在一行代码上实现它.
我想使用try with resources实现处理POST请求的代码.
以下是我的代码:
public static String sendPostRequestDummy(String url, String queryString) {
log.info("Sending 'POST' request to URL : " + url);
log.info("Data : " + queryString);
BufferedReader in = null;
HttpURLConnection con = null;
StringBuilder response = new StringBuilder();
try{
URL obj = new URL(url);
con = (HttpURLConnection) obj.openConnection();
// add request header
con.setRequestMethod("POST");
con.setRequestProperty("User-Agent", "Mozilla/5.0");
con.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
con.setRequestProperty("Content-Type", "application/json");
// Send post request
con.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
wr.writeBytes(queryString);
wr.flush();
wr.close();
int responseCode = con.getResponseCode();
log.info("Response Code : …Run Code Online (Sandbox Code Playgroud) 我想使用lambda函数创建一个FileNameFilter.
我的主要问题是我想在函数内部引入一个循环.我尝试使用过滤器,但我无法根据外部列表创建过滤器.
以下是我的代码:
File targetDir = new File(path);
FilenameFilter deleteFilter = new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
for(String tag: pageTagsList){
if(name.equals(tag))
return true;
}
return false;
}
};
File[] foundFiles = targetDir.listFiles(deleteFilter);
Run Code Online (Sandbox Code Playgroud)
我想做的是这样的:
File[] foundFiles = targetDir.listFiles(
(dir,name)->pageTagsList.stream()
.filter(//code to filter here)
.orElse(false)
);
Run Code Online (Sandbox Code Playgroud)
有没有正确的方法来做到这一点?