我正在阅读http://docs.oracle.com/javaee/7/tutorial/doc/jsf-facelets005.htm#GIQZR上的Java EE 7教程
在我的IDE中的8.5复合组件一章中键入示例代码并在GlassFish4.0上运行示例后,我收到错误
java.lang.NullPointerException
at java.util.concurrent.ConcurrentHashMap.putIfAbsent(ConcurrentHashMap.java:1078)
at com.sun.faces.util.Cache.get(Cache.java:116)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.getComponentMetadata(FaceletViewHandlingStrategy.java:237)
at com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:951)
at javax.faces.application.ApplicationWrapper.createComponent(ApplicationWrapper.java:648)
Run Code Online (Sandbox Code Playgroud)
然后我查看本教程的旧版本,我发现了一个区别.
在Java EE 7版本中,email.xhtml代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:composite="http://xmlns.jcp.org/jsf/composite"
xmlns:h="http://xmlns.jcp.org/jsf/html">
<h:head>
<title>This content will not be displayed</title>
</h:head>
<h:body>
<composite:interface>
<composite:attribute name="value" required="false"/>
</composite:interface>
<composite:implementation>
<h:outputLabel value="Email id: "></h:outputLabel>
<h:inputText value="#{cc.attrs.value}"></h:inputText>
</composite:implementation>
</h:body>
</html>
Run Code Online (Sandbox Code Playgroud)
但是在Java EE 6版本中
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:composite="http://java.sun.com/jsf/composite"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>This content will not be displayed</title>
</h:head> …Run Code Online (Sandbox Code Playgroud) 我们希望在JVM手动终止时退出之前执行一些java代码或shell代码.我们的应用程序没有在容器中运行.我们需要使用Java代码本身或某些命令行工具自动监视它.
我仅使用 ActiveRecord 进行一些旧 Oracle 数据库的开发。我的适配器是 activerecord-oracle_enhanced-adapter ( https://github.com/rsim/oracle-enhanced )。所以我不想让 AR 处理主键生成。如何禁用序列生成的主键?
class User < Activied::Base
self.table_name = "users"
self.primary_key = "user_id"
end
user = User.new
user.save
Run Code Online (Sandbox Code Playgroud)
然后我得到了错误:
stmt.c:230:in oci8lib_191.so: ORA-02289: sequence does not exist (OCIError)
Run Code Online (Sandbox Code Playgroud)
当我将代码更改为
class User < ActiveRecord::Base
self.table_name = 'users'
self.primary_key = "user_id"
self.sequence_name = nil
end
Run Code Online (Sandbox Code Playgroud)
我收到另一个错误:
stmt.c:230:in oci8lib_191.so: ORA-00936: missing expression (OCIError)
Run Code Online (Sandbox Code Playgroud)
那么有人知道如何手动管理主键吗?我只想做一些简单的插入。
谢谢
我正在使用React,React-Router和Superagent.我的Web应用程序中需要授权功能.现在,如果令牌过期,我需要将页面重定向到登录页面.
我已将ajax调用功能放在一个单独的模块中,并且令牌将在每个请求的标头上发送.在我的一个组件中,我需要通过ajax调用获取一些数据,如下所示.
componentDidMount: function() {
api.getOne(this.props.params.id, function(err, data) {
if (err) {
this.setErrorMessage('System Error!');
} else if (this.isMounted()) {
this.setState({
user: data
});
}
}.bind(this));
},
Run Code Online (Sandbox Code Playgroud)
如果我收到401(未授权)错误,可能是因为令牌过期或没有足够的权限,该页面应重定向到登录页面.现在,在我的api模块中,我必须使用window.loication="#/login"我不认为这是一个好主意.
var endCallback = function(cb, err, res) {
if (err && err.status == 401) {
return window.location('#/login');
}
if (res) {
cb(err, res.body);
} else {
cb(err);
}
};
get: function(cb) {
request
.get(BASE_URL + resources)
.end(endCallback.bind(null, cb));
},
Run Code Online (Sandbox Code Playgroud)
但是,我不能轻易地在我的api模块中调用react-router方法.有没有一种优雅的方式来实现这个简单的功能?我不想在每个需要授权的反应组件中添加错误回调.
我正在使用STS开发一个基于 Spring Boot 的大型应用程序。我们有多个 Maven 项目和一个父项目来包含它们。每个项目都有自己的测试代码和配置文件。
当我在主入口类中运行 Spring Boot 应用程序时。依赖项目的test-classes文件夹会被加载到app运行的classpath中,这会导致spring bean定义的一些冲突。我必须配置每个项目,从“构建路径上的源文件夹”中删除 [src/test/java 和 src/test/resources]。
整个项目结构如下:
app-parent
子应用程序-1
子应用程序 2
子app-3
main-app [从这个项目运行]
main-app 项目依赖于 sub-app-1 ~ 3。
有什么方法可以让 STS (Eclipse) 运行 Java 应用程序,但不包括类路径中的 test-classes 文件夹?我真的想要源文件夹下的测试代码,但在应用程序运行时没有它们。
此外,我尝试打开[运行配置],但它只能向类路径添加更多文件。
List<T> list = new ArrayList<T>();
Run Code Online (Sandbox Code Playgroud)
1方法:
for(int i = list.length - 1; i >= 0; i--) {
System.out.println(list.get(i));
}
Run Code Online (Sandbox Code Playgroud)
2方法:
for(T t : list) {
System.out.println(t);
}
Run Code Online (Sandbox Code Playgroud)
3方法:
Iterator<T> it = list.iterator();
while(it.hasNext()) {
System.out.println(it.next());
}
Run Code Online (Sandbox Code Playgroud) 我正在使用Spring3.2和JPA与Hibernate4.2.1 Final
我的一个实体代码是:
@Entity
@Table(name = "BOOLEAN_VALUES")
@Cache(region = "booleanValues", usage = CacheConcurrencyStrategy.READ_ONLY)
public class BooleanValue {
@Column(name = "NAME")
@NotEmpty
private String name;
public void setName(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
}
Run Code Online (Sandbox Code Playgroud)
我们想要缓存这种实体,因为它们的值永远不会改变.在应用程序启动之前,这些值将插入表中.这些表看起来像字典值表.
我的ehcache.xml如下:
<cache name="booleanValues"
eternal="false" maxElementsInMemory="10000"
maxElementsOnDisk="1000"
overflowToDisk="true"
diskSpoolBufferSizeMB="20"
timeToIdleSeconds="3000"
timeToLiveSeconds="6000"
memoryStoreEvictionPolicy="LFU" />
Run Code Online (Sandbox Code Playgroud)
但每次启动我的应用程序时,都会显示以下警告,我的配置是否有任何问题?如何将这些实体设置为不可变?
2013-08-21 09:36:18,983 - org.hibernate.cache.ehcache.internal.strategy.EhcacheAccessStrategyFactoryImpl -2921 [localhost-startStop-1] WARN - HHH020007: read-only cache configured for mutable entity [booleanValues]
Run Code Online (Sandbox Code Playgroud) 使用spring boot 2.它已经包含了Jackson Java8 API.但是LocalDatetime的JSON格式是一种人类可读的格式.我希望通过杰克逊成为EPOCH,只是一个真正的时间戳.
我知道如何在Java8 API中将LocatDatetime转换为EPOCH.我的问题是如何配置Spring Boot 2来做到这一点.没有添加客户ObjectMapper可以吗?
我有一个扩展ReactiveMongoRepository的MovieRepository.我想以反应方式保存单个POJO.但ReactiveMongoRepository不为Mono或Publisher提供保存方法.我必须使用block()方法或使用saveAllReactiveMongoRepository中的方法.
public Mono<ServerResponse> create(ServerRequest request) {
Mono<Movie> movieMono = request.bodyToMono(Movie.class);
return movieRepository.save(movieMono.block()) //
.flatMap((movie) -> ServerResponse.ok().body(fromObject(movie)));
}
Run Code Online (Sandbox Code Playgroud)
有没有更好的方法来解决这类问题?我不认为使用块方法是反应式编程的好主意.
spring mongodb reactive-programming spring-data-mongodb project-reactor
我使用 Reactor (Spring5 WebClient) 作为我的反应式编程 API。我有 2 个 REST 端点要调用。第一个的结果将是第二个的参数。对于第二个 API,它将返回一个带有“hasMore”值的结果。如果此值为true,我应该更改分页参数并再次调用第二个 API。演示代码如下:
client.getApi1()
.map(r -> r.getResult())
.flatMap(p -> client.getApi2(p, 2(page size), 1(page start)))
.subscribe(r -> System.out.println(r.isHasmore()));
Run Code Online (Sandbox Code Playgroud)
如何重复调用第二个 API (getApi2) 直到“hasMore”为假。
此外,我需要更改参数页面大小和页面开始
我正在使用Spring Session进行会话管理。同时,我们的应用程序中有一些REST API,我们也想使用基于令牌的身份验证。
因此,我们想一起启用2 HttpSessionStrategy CookieHttpSessionStrategy和HeaderHttpSessionStrategy。这样,我们的应用程序可以同时认证cookie和令牌。
java ×2
spring ×2
spring-boot ×2
activerecord ×1
ajax ×1
eclipse ×1
facelets ×1
jackson ×1
jsf ×1
jsf-2.2 ×1
jvm ×1
mongodb ×1
oracle ×1
performance ×1
react-router ×1
reactjs ×1
ruby ×1
spring-mvc ×1
superagent ×1
time ×1