当我们使用命名空间时,我们还应指出其关联的XSD所在的位置,如以下示例所示:
<?xml version="1.0"?>
<Artist BirthYear="1958"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.webucator.com/Artist"
xsi:schemaLocation="http://www.webucator.com/Artist Artist.xsd">
<Name>
<Title>Mr.</Title>
<FirstName>Michael</FirstName>
<LastName>Jackson</LastName>
</Name>
</Artist>
Run Code Online (Sandbox Code Playgroud)
在这里,我们已经指出Artist.xsd应该用于验证http://www.webucator.com/Artist命名空间.但是,我们也使用http://www.w3.org/2001/XMLSchema-instance命名空间,但我们没有指定其XSD所在的位置.XML解析器如何知道如何处理此命名空间?
更新(回应第一位评论者)
那么,我们可以代替使用:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ehcache="http://www.springmodules.org/schema/ehcache"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springmodules.org/schema/ehcache
http://www.springmodules.org/schema/cache/springmodules-ehcache.xsd">
...
</beans>
Run Code Online (Sandbox Code Playgroud)
使用
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ehcache="http://www.springmodules.org/schema/ehcache">
...
</beans>
Run Code Online (Sandbox Code Playgroud)
?
我的模型是这样的:
@Entity
@Table(name = "user")
public class User {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column(name="email")
private String email;
@Column(name = "weblink")
private String webLink;
//getter & setter
}
Run Code Online (Sandbox Code Playgroud)我们通过http请求收集表单或移动数据,springmvc会将这些数据发送给像用户这样的模型.
例如,我有这样的请求:
http://localhost:8080/update?id=1919&email=xx@google.com
在控制器中,请求URL及其参数将自动转换为User对象.
@RequestMapping(method = RequestMethod.GET, value = "/update0")
public User update(@ModelAttribute("User") User user){
System.out.println(user.getId());
System.out.println(user.getEmail());
System.out.println(user.getWebLink());
return userRepository.save(test);
}
Run Code Online (Sandbox Code Playgroud)如果我在mysql中有一个id为1919的记录,并且列(id,email,weblik)都有值.
如您所见,通过Web或移动设备传递的用户对象具有两个属性
http://localhost:8080/update?id=1919&email=xx@google.com
id和电子邮件有值,而weblink没有.
因此,如果我执行save方法,列电子邮件将更新为xx@google.com,weblik字段也将更新为NULL,但我不想更新此字段,我只想更新电子邮件字段.
我有两种方法来解决这个问题,但所有这些方法都不优雅.
5.1首先加载用户对象并更新
User userExist = userRepository.findOne(user.getId());
userExist.setEmail(user.getEmail());
//or using
//BeanUtil.copyProprty(formDto,modle)
userRepository.save();
Run Code Online (Sandbox Code Playgroud)
5.2使用@DynamicUpdate,但不起作用.
是否有其他方法来更新用户模型,不做一些额外的工作.
提前致谢.
我有一个有两排的桌子.第一行包含一个input,第二行包含一个select.即使我将宽度设置为100%,选择框也比输入小几个像素.任何想法为什么会这样,我怎么能以一种适用于所有(A级)浏览器的方式将它们的宽度设置为彼此相等并尽可能大(例如%100)?
<table width="100%" style="margin-top: 5px;">
<tr>
<td width="35"><label for="desc">Description</label></td>
<td>
<input type="text" style="width: 100%;" name="desc" id="desc" />
</td>
</tr>
<tr>
<td width="35"><label for="group">Group</label></td>
<td>
<select id="group" name="group" style="width: 100%; line-height: 17px;">
<option value="val">name</option>
</select>
</td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud) 我通常将从Web下载的Java应用程序和JAR文件存储在我的计算机(OS X机器)上的〜/ Java文件夹中.自从我成为Windows用户以来,我一直在这样做.但是我认为在基于UNIX的系统中,用户本地应用程序通常存储在另一个目录中.我有一种感觉,这个目录应该不包括/usr/local/,/usr/local/USERNAME,/opt/local,或/opt/local/USERNAME,但我不知道.我可以将任何目录用于此目的吗?
请注意,我说的是我从Web下载的归档文件,在本地解压缩和使用,而不是具有安装脚本或MacPorts的程序等.
我开发了一个客户维护应用程序.用户可以通过Web界面更改客户详细信息.我想处理以下场景:
User 1加载customer1细节.User 2加载customer1细节.User 1修改并保存customer1的name.User 2只改变和保存customer1的年龄.在上面的场景中,最后数据库保留了customer1旧名称和新时代,因为User 2覆盖了User 1更新.我正在使用Hibernate.我听说Hibernate自动版本控制支持这一点.如果有人知道如何处理这个请告诉我.
是否有可靠且众所周知的NoSQL DB支持JTA事务?在我的应用程序中,我需要将一些数据存储到RDBMS DB,并将一些数据存储到同一事务中的NoSQL DB,我将JTA用于我的RDBMS事务.
已经发布了关于将javascript放在元素内与关闭body标签()之前的优缺点的条目.<head></body>
但是我发现有时开发人员会将JavaScript代码放在HTML页面的任意位置.这似乎主要是由于懒惰.在页面的任意位置嵌入JavaScript代码有什么缺点?存在许多明显的缺点,例如没有缓存,重用次数较少等.在这方面您还能想到哪些其他缺点?
感谢asdvance.
让我们假设我们有两个Closeablebean:
@Component
public class CloseableBean1 implements Closeable {
private BufferedOutputStream outputStream;
@Override
public void close() throws IOException {
try {
outputStream.close();
} catch (Exception e) {
// ignore e
}
}
}
@Component
public class CloseableBean2 implements Closeable {
@Autowired
private CloseableBean1 bean1;
@Override
public void close() throws IOException {
try {
bean1.close();
} catch (Exception e) {
// ignore e
}
}
}
Run Code Online (Sandbox Code Playgroud)
Spring 是否确保CloseableBean2先CloseableBean1关闭再关闭?
有人知道任何Spring Boot与Kafka Connect的集成吗?我认为有一个spring-kafka项目可以很好地与Kafka客户端集成,但不能连接和流式API.
spring spring-integration spring-xd spring-boot apache-kafka-connect
建立这个Dockerfile:
FROM ubuntu:19.10
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update
RUN apt-get install -y locales apt-utils
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
dpkg-reconfigure locales && \
update-locale LANG=en_US.UTF-8
ENV LANG en_US.UTF-8
RUN apt-get install --no-install-recommends -y vim
CMD /bin/bash
Run Code Online (Sandbox Code Playgroud)
输出一些警告消息:
update-alternatives: warning: skip creation of /usr/share/man/da/man1/vi.1.gz because associated file /usr/share/man/da/man1/vim.1.gz (of link group vi) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/de/man1/vi.1.gz because associated file /usr/share/man/de/man1/vim.1.gz (of link group vi) doesn't exist
update-alternatives: warning: …Run Code Online (Sandbox Code Playgroud) java ×4
spring ×3
spring-boot ×2
css ×1
docker ×1
dockerfile ×1
hibernate ×1
html ×1
javascript ×1
jpa ×1
jta ×1
linux ×1
macos ×1
nosql ×1
spring-data ×1
spring-mvc ×1
spring-xd ×1
ubuntu ×1
ubuntu-19.04 ×1
unix ×1
xml ×1
xsd ×1