小编Kir*_*rov的帖子

IntelliJ IDEA生成serialVersionUID

如何在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)

java serialization intellij-idea

287
推荐指数
7
解决办法
21万
查看次数

OutOfMemoryError:Jboss AS 7和IntelliJ IDEA上调试模式下的PermGen空间

我正在使用IntelliJ IDEAJBOSS AS 7.当我尝试在调试模式下部署我的应用程序时,我发生此异常java.lang.OutOfMemoryError: PermGen space,服务器没有回答.但是如果我使用Eclipse,那么同一台服务器就没有这样的问题了!我怎么能解决这个问题?

intellij-idea jboss7.x

12
推荐指数
1
解决办法
8390
查看次数

注入HttpServletRequest

我正在使用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)

我该怎么办?

java dependency-injection ejb jboss7.x

12
推荐指数
2
解决办法
2万
查看次数

iOS 6中的导航栏在iOS 7中看起来像吧

有没有办法让iOS 6中的导航栏元素(后退按钮)看起来像iOS 7中的导航栏元素?还有按钮和其他iOS 7元素的UI.

uinavigationbar ios6 ios7

7
推荐指数
1
解决办法
6267
查看次数

IllegalArgumentException:期望IdClass映射

在部署我的应用程序期间,我发生在该异常上.我的应用程序中有很多课程,我不知道我必须放在@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)

java hibernate jboss7.x

6
推荐指数
2
解决办法
2万
查看次数

Java 8 流组by pojo

我有一系列 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 java-8 java-stream collectors

5
推荐指数
1
解决办法
1041
查看次数

Java方法引用解析

我试图理解方法引用如何在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)

???

java java-8 method-reference

5
推荐指数
1
解决办法
192
查看次数

maven找不到包裹和符号

我有这个类的应用程序:(类的一部分):

@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制作时没有这样的问题.可能是什么?

java maven

4
推荐指数
1
解决办法
6207
查看次数

如何使用LINQ在Dictionary中查找元素

我有一个代码:

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做到这一点?

c# linq

2
推荐指数
1
解决办法
129
查看次数

如何在一行JSF中创建元素

如何使元素在一行中呈现如下图所示:

在此输入图像描述

这是代码:

                                <h:outputLabel
                                        value="&#160;#{cdocmsgs['promo.action.name']}&#160;"
                                        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="&#160;#{cdocmsgs['source.of.info']}&#160;"
                                               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但它没有帮助.

jsf

1
推荐指数
1
解决办法
4120
查看次数