我正在开发一个Spring/Vaadin/Hibernate应用程序.
一切正常但我仍然在Eclipse STS 2.8.1中有以下错误标记:
The hierarchy of the type BankView is inconsistent
The hierarchy of the type AbstractEntityView is inconsistent
Run Code Online (Sandbox Code Playgroud)
我的观点有以下结构:
public class BankView extends AbstractEntityView {
@Resource private BankService bankService;
public void buildLayout() {
super.buildLayout();
// Use of the service here
}
}
public abstract class AbstractEntityView extends AbstractView {
public void buildLayout() {
verticalLayout = new VerticalLayout();
verticalLayout.setSpacing(true);
verticalLayout.setSizeFull();
setContent(verticalLayout);
super.buildLayout();
}
}
@Configurable(preConstruction = true)
public abstract class AbstractView extends com.vaadin.ui.VerticalLayout {
public AbstractView() {
super();
try …Run Code Online (Sandbox Code Playgroud) 在Oracle论坛,Stackoverflow,java.net上阅读了有关此内容的所有帖子后,我终于在这里发帖了.我正在使用JAXB来创建XML文件,但问题是它在我的元素之前添加了着名的ns2前缀,我已经尝试了所有没有人为我工作的解决方案.java -version给出"1.6.0_37"
解决方案1:使用package-info.java
我在我的包中创建了包含带有以下内容的@ Xml*注释类的文件:
@XmlSchema(
namespace = "http://mynamespace",
elementFormDefault = XmlNsForm.QUALIFIED,
xmlns = {
@XmlNs(namespaceURI = "http://mynamespace", prefix = "")
}
)
package com.mypackage;
import javax.xml.bind.annotation.XmlNs;
import javax.xml.bind.annotation.XmlNsForm;
import javax.xml.bind.annotation.XmlSchema;
Run Code Online (Sandbox Code Playgroud)
解决方案2:NamespacePrefixMapper
我创建了以下类并将映射器设置为marshaller:
// Change mapper to avoid ns2 prefix on generated XML
class PreferredMapper extends NamespacePrefixMapper {
@Override
public String getPreferredPrefix(String namespaceUri, String suggestion, boolean requirePrefix) {
return "";
}
}
NamespacePrefixMapper mapper = new PreferredMapper();
try {
marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper", mapper);
}
catch (PropertyException e) {
logger.info("No property …Run Code Online (Sandbox Code Playgroud) 经过对谷歌的一些研究,我没有找到任何有我问题的人,这就是我在这里发布的原因.在我的应用程序中,我有三个实体:用户(摘要),客户,代理商.客户和代理商扩展用户.这是用户的代码:
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public abstract class User extends AbstractModel {
@Column(unique = true)
@NotNull
@Email
public String email;
@NotNull
public String password;
}
Run Code Online (Sandbox Code Playgroud)
问题是生成的模式只创建一个包含User,Customer和Agency字段的表,这通常是InheritanceType.SINGLE_TABLE(默认)的行为.
使用Ebean和@Inheritance注释有什么问题吗?我尝试了InheritanceType.TABLE_PER_CLASS,它也没有用.我从来没有使用JPA这个问题.有人可以帮忙吗?
非常感谢 ;)
这是与我的控制器方法对应的路径:
GET /my-resources controllers.MyResourceController.list(from: String ?= null, pageSize: Integer ?= null, sort: String ?= null)
Run Code Online (Sandbox Code Playgroud)
我没有问题,使用from,pageSize并sort在我的查询参数,但我无法找到如何使用过滤器做.我希望能够过滤实体的每个字段,但我想找到一种方法来避免在路由中添加我的实体的每个属性(即:代码,名称,描述......)
那种应该有效的电话:
https://myapi.com/my-resources?sort=name,description&name=MyName&description=Blablabla
Run Code Online (Sandbox Code Playgroud)
在我的控制器中,我通过浏览对我的数据库查询应用过滤器request().queryString().所以我的问题是如何添加查询字符串参数FakeRequest以测试我的控制器?如果您有更好的方法在请求中传递过滤器,请不要犹豫.
谢谢
在我的节点项目中,我使用 ESLint。我想对进口商品进行排序。我配置了它,现在一切正常。但是,我无法对导入进行分组和排序。
import request from 'request';
import { asyncHandler } from 'middleware';
import { githutOptions } from 'constants/options.constant';
import profileService from 'services/profile.service';
Run Code Online (Sandbox Code Playgroud)
在这里,我收到一条警告,指出导入应按字母顺序排序。在第二行。(异步处理程序)
为什么不根据分组进行排序?在我参与的另一个项目中,如果有多个分组导入,则仅在这些组内进行排序。
但在这里,即使我将这些导入分组,它也会考虑整个文件,因此 asyncHanler 应该作为第一行。我在这里想要的是仅对组内的导入进行排序。
我怎样才能实现这个目标?
这些是我对导入进行排序的 eslint 规则。
"sort-imports": ["error", {
"ignoreCase": false,
"ignoreDeclarationSort": false,
"ignoreMemberSort": false,
"memberSyntaxSortOrder": ["none", "all", "single", "multiple"]
}]
Run Code Online (Sandbox Code Playgroud) 我生成的服务器端与以下参数预先签署的URL请求GeneratePresignedUrlRequest:bucket,key,expiration = in 1 hour和method = PUT.
在我的Angular应用程序中,我使用ng-file-upload上传文件
Upload.http({
url: $scope.signedUrl,
method: "PUT",
headers : {
'Content-Type': $scope.file.type
},
data: $scope.file
});
Run Code Online (Sandbox Code Playgroud)
问题是我总是有一个403响应,除非我设置文件的类型GeneratePresignedUrlRequest.contentType.
问题是,我不能提前预知的用户会选择什么类型的文件(image/png,image/jpeg,text/plain...).
如何生成接受各种类型的预签名网址content-type?我尝试将其设置为null,它一直发送403错误.
谢谢.
我是Play2的新手(我已经使用Play1开发了一个项目),我遇到了来自请求的表单绑定问题.关于表单的文档非常简单.
这是我的控制器的代码:
private final static Form<Estimation> estimationForm = form(Estimation.class);
/**
* Get an estimation by form
* @return
*/
public static Result estimation() {
return ok(views.html.rate.estimation.render(
estimationForm,
City.findAll()
));
}
/**
* Display estimation results
* @return
*/
public static Result results() {
if (request().method().equals("POST")) {
Form<Estimation> form = estimationForm.bindFromRequest();
if (form.hasErrors()) {
System.out.println(form.errorsAsJson().toString());
return ok(views.html.rate.estimation.render(
form
City.findAll()
));
}
else {
System.out.println(form.get());
return ok(views.html.rate.results.render(
));
}
}
else {
return estimation();
}
}
Run Code Online (Sandbox Code Playgroud)
我在选择中显示城市:
<select id="city" name="city">
<option value="1">Paris, …Run Code Online (Sandbox Code Playgroud) 我正在发现Nodejs和node-mysql模块.我有一个小问题.我找到的每个教程都解释了如何对数据库进行选择,但它们永远不会返回行,它们总是记录它们,这对我的情况来说绝对没用.
我有一个app.js文件:
// Get continents
app.get("/continents", function(request, result) {
console.log("Continents : " + database.findAllContinents());
});
Run Code Online (Sandbox Code Playgroud)
和一个mysql.js文件:
exports.findAllContinents = function(connection) {
var connection = getConnection();
connection.query('select id, code, name from Continent', function (err, rows, fields) {
if (err) {
console.log("Error in findAllContinents : " + err)
}
return JSON.stringify(rows);
});
closeConnection(connection);
};
Run Code Online (Sandbox Code Playgroud)
如何让函数返回行以在app.js文件中使用它们?我真的不想在app.js文件中创建连接我想要分离DAO层.你有什么主意吗 ?
此外,如果有人知道使用node-mysql而不是ORM(sequelize,persistence.js ......)的优缺点
谢谢
我的应用程序中有一个具有以下结构的标签:
@(
columns: Integer
)(header: Html)(body: Html)
<table>
@if(header != null) {
<thead>
<tr>
@header
</tr>
</thead>
}
// Body and foot here
</table>
Run Code Online (Sandbox Code Playgroud)
我在我的模板中使用它,如下所示:
@tags.Table(5) { } {
// My content here
}
Run Code Online (Sandbox Code Playgroud)
前面的代码不起作用:即使我让括号为空,也会<thead></thead>显示 。那么如何检查header不为空、null...以及如何在模板中声明我的标签?也许我用 来声明是错误的{ }?
如果我用 声明它{},则会出现以下错误:
type mismatch;
found : Unit
required: play.twirl.api.Html
Run Code Online (Sandbox Code Playgroud) 我正在使用CQRS和Event Sourcing实施一个项目.我意识到我的命令和我的事件几乎总是一样的.
假设我有一个命令CreatePost:
public class CreatePost implements Command {
private final String title;
private final String content;
}
Run Code Online (Sandbox Code Playgroud)
从此命令触发的事件是相同的:
public class PostCreated implements Event {
private final String title;
private final String content;
}
Run Code Online (Sandbox Code Playgroud)
你如何处理你的应用程序?
编辑:当然我知道基本的OOP技术.我可以创建具有公共字段的抽象,但是这个问题需要在CQRS/ES上下文中进行.