小编Has*_*lah的帖子

从JBoss 7迁移到WildFly 9时使用CMT的EJB

我正在将我的应用程序从JBoss 7迁移到WildFly(v9.0.1),并且由于bean事务管理错误而未部署它.

    Caused by: javax.naming.NamingException: WFLYNAM0062: Failed to lookup env/com.component.eventmgt.EventServiceImpl/transaction [Root exception is java.lang.RuntimeException: WFLYNAM0059: Resource lookup for injection failed: java:jboss/UserTransaction]
    at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:157)
    at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:83)
    at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:207)
    at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:193)
    at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:189)
    at org.jboss.as.naming.deployment.ContextNames$BindInfo$1$1.getReference(ContextNames.java:316)
    ... 90 more
Caused by: java.lang.RuntimeException: WFLYNAM0059: Resource lookup for injection failed: java:jboss/UserTransaction
    at org.jboss.as.naming.deployment.ContextNames$BindInfo$1$1.getReference(ContextNames.java:319)
    at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:143)
    ... 95 more
Caused by: javax.naming.NameNotFoundException: UserTransaction [Root exception is java.lang.IllegalStateException: WFLYEJB0137: Only session and message-driven beans with bean-managed transaction demarcation are allowed to access UserTransaction]
    at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:153)
    at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:83) …
Run Code Online (Sandbox Code Playgroud)

transactions ejb-3.0 java-ee-6 jboss7.x wildfly-9

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

本机实现抽象方法

Java中是否允许在类中使用抽象方法,然后使用JNI将其实现在使用本机语言的其他方法中.

例:

abstract class Mommy {
abstract protected void call();
}
class Son extends Mommy {
 native protected void call() /*
'native code'
*/
}
Run Code Online (Sandbox Code Playgroud)

什么是预期的行为是可能发生的运行时错误还是"解决方法"的一切都很好?

java java-native-interface abstract-class

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

Spring Boot 安全性,具有 3 个字段身份验证和自定义登录表单

我正在使用 Spring Boot,我需要使用 3 个字段身份验证过程用户名、密码和公司标识符来实现 Spring Security,作为表单中的隐藏输入。

我实现了一个自定义的用户名密码身份验证过滤器,但它似乎不足以设置安全配置。

编辑 :

用户似乎没有经过身份验证!因为 a 可以访问 Web 配置中定义的经过身份验证的请求

编辑2:

在我的自定义过滤器中,当输入有效用户时,它会在 successfulAuthentication 上执行。我缺少什么,请为我提供任何帮助:( 我在这里

@Repository
public class AuthenticationUserDetailsService implements UserDetailsService {

private static final Logger LOGGER = Logger.getLogger(AuthenticationUserDetailsService.class);

@Autowired
private UserRepository users;

private org.springframework.security.core.userdetails.User userdetails;

@Override
public UserDetails loadUserByUsername(String input) throws UsernameNotFoundException {
    // TODO Auto-generated method stub

    System.out.println(input);
    String[] split = input.split(":");
    if (split.length < 2) {
        LOGGER.debug("User did not enter both username and corporate domain.");
        throw new UsernameNotFoundException("no corporate identifier is specified"); …
Run Code Online (Sandbox Code Playgroud)

java security spring spring-security spring-boot

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

如何使用materializecss自己的材料设计图标?

我需要知道如何在自定义类中添加自己的mdi图标.提供的mdi课程不符合我的期望.

我如何添加它们并像默认一样使用它们

<i class="mdi-image-facebook"></i>
<i class="mdi-image-linkedin"></i>
Run Code Online (Sandbox Code Playgroud)

提前致谢

css materialize material-design

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

在 DateTimeFormatter 中处理多种格式

String我正在使用 Java 8 开发一个函数,该函数必须处理以下LocalDateTime日期的转换:

  • 2019-06-20 12:18:07.207 +0000 世界标准时间
  • 2019-06-20 12:18:07.20 +0000 世界标准时间
  • 2019-06-20 12:18:07.2 +0000 世界标准时间
  • 2019-06-20 12:18:07 +0000 世界标准时间

这些字符串是从我无法更改的外部库生成的。

按照SO答案Optional parts in SimpleDateFormat中给出的建议,我尝试使用 type 提供的可选格式DateTimeFormatter,使用字符[]。我尝试了以下模式:

  • yyyy-MM-dd HH:mm:ss[.S[S[S]]] Z z
  • yyyy-MM-dd HH:mm:ss[.S[S][S]] Z z

然而,它们都不起作用。

有什么建议吗?

java date-formatting java-8 dateformatter

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

使用自定义函数从多个源Java 8构造对象

我有多个来源(地图),我在其中存储与旨在构造具有ID的最终对象的不同属性相关的数据。这些地图根据此模式具有不同的结构:

地图

  • id是我的最终对象FinalObject的标识符
  • X1,X2是我的最终对象FinalObject的属性

在实际代码中,我有以下几张地图:

Map<Integer, String> descriptions;
Map<Integer, Double> prices;
Map<Integer, Double> quantities;
Map<Integer, String> currencies;
Run Code Online (Sandbox Code Playgroud)

我可以合并我的集合流,Stream.of()但是我要处理两个问题,即异构映射的结构,还要为每个条目创建Java8方式的Final对象。

我认为我的MultipleFunctionBiFunction 是我为FinalObject定义的属性作为参数。作为设计可以吗?

有任何意见或建议吗?

合并的结果如下:

Stream.of(descriptions.entrySet(), prices.entrySet(), quantities.entrySet(), currencies.entrySet())
        .flatMap(Set::stream)
        .collect(Collectors.toMap(Map.Entry::getKey, entry -> new FinalObject(description, price, quantity, currency)));
Run Code Online (Sandbox Code Playgroud)

这段代码不会编译,对于我的问题来说,这是更好的理解。

java design-patterns java-8 java-stream

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

使用没有FXML的JavaFX控制器

是否有可能在不使用FXML的情况下使用带有JavaFX GUI的控制器.

我注意到FXML文件包含fx-controller绑定控制器的属性,但我发现它不是一种简单的方法来使用它.

有关在不使用FXML文件或JavaFX Scene Builder的情况下使用JavaFX创建MVC的任何想法?

java fxml javafx-8

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

将规则从UML映射到面向列的NoSQL数据库

因为我正在开发一个将UML类图转换为NoSQL cassandra数据库的新项目.我很难找到类似于关系模型的基本翻译规则.正如我在cassandra文档中读到的那样,它是面向查询的建模.但是在实现之前是否存在任何通用规则概念.请帮忙

uml class-diagram column-oriented cassandra nosql

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

jdbcTemplate setQueryTimeout 值类型

public void setQueryTimeout(int queryTimeout)我想知道我们需要传入的值的类型是什么jdbcTemplate。文件说

> Set the query timeout for statements that this JdbcTemplate executes.
> <p>Default is -1, indicating to use the JDBC driver's default (i.e. to
> not pass a specific query timeout setting on the driver). <p>Note: Any
> timeout specified here will be overridden by the remaining transaction
> timeout when executing within a transaction that has a timeout
> specified at the transaction level. @see
> java.sql.Statement#setQueryTimeout
Run Code Online (Sandbox Code Playgroud)

想知道queryTimeout是否是milliseconds, …

java jdbc jdbctemplate java-8 query-timeout

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

动态字段thymeleaf列表迭代

我收到一个非常奇怪的错误!在列表上迭代时,百万美元将索引识别为我的bean的属性,而不是索引值!

<div th:each="phoneStat : *{phones}">
    <select th:field="*{phones[__${phoneStat.index}__].variety}">
        <option></option>
    </select>
    <div class=" input-field col s4">
        <input class="validate" th:field="*{phones[__${phoneStat.index}__].number}"
               th:id="${'phonenumber-'+ phones[__${phoneStat.index}__]}" type="text"/>
        <label th:for="${'phonenumber-'+ phones[__${phoneStat.index}__]}"> Mobile</label>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

我在这做错了什么?请帮忙!

2015-06-15 15:48:25.453 ERROR 7764 --- [nio-8080-exec-6] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "phoneStat.index" (/custom:89)] with root cause

org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 10): Property or field 'index' cannot be found on object of type 'com.ubleam.corporate.server.model.Phone' - maybe not …
Run Code Online (Sandbox Code Playgroud)

spring spring-mvc thymeleaf spring-boot

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

使用 thymeleaf 在另一个变量中显示变量

我有一个 th:each 循环,其中一个显示按钮。

<li th:id="${'button-' + row.name }" th:unless="${row.name == 'linkedin' or row.name == 'slideshow'}" class="collection-item avatar" th:each="row, rowStat: *{arButtons}">
        <img th:src="${'/images/buttons/' + row.name + '.png'}" th:alt="${row.name}" class="circle"/>
            <div class=" input-field col s12">
                <input th:field="*{arButtons[__${rowStat.index}__].name}" type="hidden" />
                <input th:field="*{arButtons[__${rowStat.index}__].data}" th:id="${'button-'+rowStat.index}" type="text" class="validate" /> 
                <label th:if="${row.name == 'call'}" th:for="${'button-'+rowStat.index}" th:text="${call}"> Phone number </label>
                <label th:if="${row.name == 'mail'}" th:for="${'button-'+rowStat.index}" th:text="${mail}"> Email </label>
                <label th:if="${row.name == 'link'}" th:for="${'button-'+rowStat.index}" th:text="${link}"> Web Link </label>
                <label th:if="${row.name == 'video'}" th:for="${'button-'+rowStat.index}" th:text="${video}"> Video </label>
            </div>
        </li>
Run Code Online (Sandbox Code Playgroud)

现在我不想每次都使用来检查 …

spring spring-mvc thymeleaf

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