如何在IntelliJ IDEA中生成此值?
我转到设置 - > 错误 - > 序列化问题 - >没有'serialVersionUID'的Serializable类,但它仍然没有显示警告.我的类PKladrBuilding父实现接口Serializable.
部分代码:
public class PKladrBuilding extends PRQObject
public abstract class PRQObject extends PObject
public abstract class PObject implements Serializable
Run Code Online (Sandbox Code Playgroud) 我正在使用IntelliJ IDEA和JBOSS AS 7.当我尝试在调试模式下部署我的应用程序时,我发生此异常java.lang.OutOfMemoryError: PermGen space,服务器没有回答.但是如果我使用Eclipse,那么同一台服务器就没有这样的问题了!我怎么能解决这个问题?
我正在使用ejb 3并尝试@Inject HttpServletRequest,但在部署时我发生异常.
码:
@Inject private HttpServletRequest httpRequest;
Run Code Online (Sandbox Code Playgroud)
例外:
org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [HttpServletRequest] with qualifiers [@Default] at injection point [[field] @Inject private com.kmware.ttk.highway.beans.session.UserSessionBean.httpRequest]
Run Code Online (Sandbox Code Playgroud)
我该怎么办?
有没有办法让iOS 6中的导航栏元素(后退按钮)看起来像iOS 7中的导航栏元素?还有按钮和其他iOS 7元素的UI.
在部署我的应用程序期间,我发生在该异常上.我的应用程序中有很多课程,我不知道我必须放在@IdClass哪里,无论如何这个例外意味着什么.我正在使用Hibernate 4.1和JBoss AS 7.1
12:10:23,761 INFO [org.hibernate.engine.jdbc.internal.LobCreatorBuilder] (MSC service thread 1-5) HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException
12:10:24,075 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] (MSC service thread 1-5) HHH000389: Unsuccessful: drop sequence hibernate_sequence
12:10:24,076 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] (MSC service thread 1-5) ERROR: sequence "hibernate_sequence" does not exist
12:10:24,281 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-5) MSC00001: Failed to start service jboss.persistenceunit."kladr.ear/kladr-ejb-1.0-SNAPSHOT.jar#primary": org.jboss.msc.service.StartException in service jboss.persistenceunit."kladr.ear/kladr-ejb-1.0-SNAPSHOT.jar#primary": Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1767) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_35]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_35] …Run Code Online (Sandbox Code Playgroud) 我有一系列 pojo:
public class Foo {
String name;
String date;
int count;
}
Run Code Online (Sandbox Code Playgroud)
我需要按名称和总和计数遍历集合、groupBy Foos,然后使用总和计数的 pojo 创建新集合。
这是我现在的做法:
List<Foo> foosToSum = ...
Map<String, List<Foo>> foosGroupedByName = foosToSum.stream()
.collect(Collectors.groupingBy(Foo::getName));
List<Foo> groupedFoos = foosGroupedByName.keySet().stream().map(name -> {
int totalCount = 0;
String date = "";
for(Foo foo: foosGroupedByName.get(name)) {
totalCount += foo.getCount();
date = foo.getDate() //last is used
}
return new Foo(name, date, totalCount);
}).collect(Collectors.toList());
Run Code Online (Sandbox Code Playgroud)
有没有更美的方式来处理流?
更新感谢大家的帮助。所有的答案都很棒。我决定在 pojo 中创建合并功能。
最终的解决方案如下所示:
Collection<Foo> groupedFoos = foosToSum.stream()
.collect(Collectors.toMap(Foo::getName, Function.identity(), Foo::merge))
.values();
Run Code Online (Sandbox Code Playgroud) 我试图理解方法引用如何在java中工作.乍一看,它非常简单.但是当谈到这样的事情时:
Foo类中有一个方法:
public class Foo {
public Foo merge(Foo another) {
//some logic
}
}
Run Code Online (Sandbox Code Playgroud)
在另一个类Bar中有一个这样的方法:
public class Bar {
public void function(BiFunction<Foo, Foo, Foo> biFunction) {
//some logic
}
}
Run Code Online (Sandbox Code Playgroud)
并使用方法参考:
new Bar().function(Foo::merge);
Run Code Online (Sandbox Code Playgroud)
它符合并且有效,但我不明白它是如何匹配的:
Foo merge(Foo another)
Run Code Online (Sandbox Code Playgroud)
到BiFunction方法:
R apply(T t, U u);
Run Code Online (Sandbox Code Playgroud)
???
我有这个类的应用程序:(类的一部分):
@SessionScoped
@Named
public class UserSessionBean implements Serializable {
@javax.ws.rs.core.Context private HttpServletRequest httpRequest;
Run Code Online (Sandbox Code Playgroud)
在mvn编译期间,我有这个错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.1:compile (default-compile) on project highway-web: Compilation failure: Compilation failure:
[ERROR] /home/kelevra/java/git/ttkHighway/highway-web/src/main/java/com/kmware/ttk/highway/beans/session/UserSessionBean.java:[28,25] package javax.servlet.http does not exist
[ERROR]
[ERROR] /home/kelevra/java/git/ttkHighway/highway-web/src/main/java/com/kmware/ttk/highway/beans/session/UserSessionBean.java:[40,38] cannot find symbol
[ERROR] symbol : class HttpServletRequest
[ERROR] location: class com.kmware.ttk.highway.beans.session.UserSessionBean
[ERROR] -> [Help 1]
Run Code Online (Sandbox Code Playgroud)
在IDEA制作时没有这样的问题.可能是什么?
我有一个代码:
var status = ...
var StatusMapping = new Dictionary<AnotherStatus, IList<Status>>
{
{
AnotherStatus,
new List<Status>
{
Status1,
Status2
}
}
}
foreach (var keyValuePair in StatusMapping)
{
if (keyValuePair.Value.Contains(status))
{
return keyValuePair.Key;
}
}
throw Exception();
Run Code Online (Sandbox Code Playgroud)
我是C#的新手,从Java切换到了C#。在Java中,可以很容易地做到这一点:
return StatusMapping
.entrySet()
.stream()
.filter(e -> e.getValue().contains(status))
.map(Map.Entry::getKey)
.findFirst()
.orElseThrow(() -> new Exception());
Run Code Online (Sandbox Code Playgroud)
有没有办法用LINQ做到这一点?
如何使元素在一行中呈现如下图所示:

这是代码:
<h:outputLabel
value=" #{cdocmsgs['promo.action.name']} "
id="promo_action_name_id"/>
<h:selectOneMenu id="promotion" widgetVar="sub" tabindex="206"
styleClass="select-fix-average"
value="#{cdocBean.entity.promoActionName}" effect="fade"
required="#{cdocBean.entity.promotion}" requiredMessage="#{cdocmsgs['enter.promo']}">
<f:selectItem itemLabel="#{cdocmsgs['promoSelect']}"
itemValue="" />
<f:selectItems value="#{promoActionBean.DAO.resultList}"
var="item" itemLabel="#{item.name}" itemValue="#{item.name}" />
</h:selectOneMenu>
<h:outputText value="" />
<h:outputText value="" />
<h:outputLabel value=" #{cdocmsgs['source.of.info']} "
id="whenId"/>
<h:selectOneMenu id="source" widgetVar="sub"
styleClass="select-fix-average"
value="#{cdocBean.entity.source}" effect="fade" tabindex="206"
required="#{cdocBean.entity.promotion}" requiredMessage="#{cdocmsgs['enter.source']}">
<f:selectItem itemLabel="#{cdocmsgs['sourceSelect']}"
itemValue="" />
<f:selectItems value="#{adSourceBean.DAO.resultList}" var="item"
itemLabel="#{item.name}" itemValue="#{item.name}" />
</h:selectOneMenu>
Run Code Online (Sandbox Code Playgroud)
我已经放置了h:panelGroup但它没有帮助.