我使用JAXB来创建文件夹和文件层次结构
我的模特:
@XmlRootElement
public class Root {
@XmlAttribute
private String path;
@XmlElement(name = "dir")
private ArrayList<Dir> rootContentDirs = null;
@XmlElement(name = "file")
private ArrayList<FileObj> rootContentFiles = null;
public void setRootContentDirs(ArrayList<Dir> rootContentDirs) {
this.rootContentDirs = rootContentDirs;
}
public void setRootContentFiles(ArrayList<FileObj> rootContentFiles) {
this.rootContentFiles = rootContentFiles;
}
public void setPath(String path) {
this.path = path;
}
}
public class Dir {
@XmlAttribute
private String name;
@XmlElement(name = "dir")
private ArrayList dirs = null;
@XmlElement(name = "file")
private ArrayList files = null;
public …Run Code Online (Sandbox Code Playgroud) 我项目的结构:
-src
--main
---java
----makers
-----SomeClass
---resources
----htmlPattern.vm
Run Code Online (Sandbox Code Playgroud)
如何告诉SomeClass关于htmlPattern.我尝试这样的事情:
VelocityEngine ve = new VelocityEngine();
Properties properties = new Properties();
properties.setProperty("resource.loader", "file");
properties.setProperty("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.FileResourceLoader");
properties.setProperty("file.resource.loader.path", "resources");
properties.setProperty("file.resource.loader.cache", "true");
properties.setProperty("file.resource.loader.modificationCheckInterval", "2");
ve.init(properties);
Template t = ve.getTemplate("htmlPattern.vm", "utf-8");
Run Code Online (Sandbox Code Playgroud)
怎么了?IDE说:
org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource 'htmlPattern.vm'
Run Code Online (Sandbox Code Playgroud) 我在尝试更新实体列表(作业)时遇到错误:
Multiple representations of the same entity [com.introlabsystems.upworkscraper.model.entities.Skill#42] are being merged. Detached: [Skill(id=42, skillName=Web Scraping)]; Detached: [Skill(id=42, skillName=Web Scraping)]
Run Code Online (Sandbox Code Playgroud)
我认为这是三个实体与技能实体具有多对多关系的情况。
@Entity
public class Job {
@Id
@Column(unique = true, nullable = false)
@SerializedName(value = "ciphertext")
private String id;
@Column(length = 2048)
private String title;
@Column(columnDefinition = "TEXT")
@JsonAdapter(value = DescriptionAdapter.class)
private String description;
@SerializedName(value = "subcategory2")
private String category;
@ManyToMany(cascade = {
CascadeType.MERGE
}, fetch = FetchType.EAGER)
@JoinTable(
joinColumns = {@JoinColumn(name = "job_id")},
inverseJoinColumns = {@JoinColumn(name = "skill_id")}
)
@JsonAdapter(value …Run Code Online (Sandbox Code Playgroud)