小编Pet*_*zov的帖子

UnknownEntityTypeException:无法找到持久化器

我想在 Wildfly 上使用 JPA 和 Spring。我尝试了这个配置:

应用程序属性:

spring.jmx.enabled=false
spring.datasource.jndi-name=java:/global/production
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
spring.jpa.show-sql = true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MariaDBDialect
spring.jpa.hibernate.ddl-auto = create-drop
Run Code Online (Sandbox Code Playgroud)

POM 文件:

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.3.RELEASE</version>
        <relativePath />
    </parent>

    <dependencies>   
        <dependency>
            <groupId>com.fasterxml.jackson.module</groupId>
            <artifactId>jackson-module-jaxb-annotations</artifactId>
            <version>2.9.5</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>                
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>       
        <dependency>
            <groupId>org.springframework.session</groupId>
            <artifactId>spring-session-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
    </dependencies>
Run Code Online (Sandbox Code Playgroud)

配置:

@Configuration
@ComponentScan("org.rest.api.server.*")
public class AppConfig {

    @Bean
    public EntityManager entityManager(EntityManagerFactory emf) {
        return emf.createEntityManager();
    }
}
Run Code Online (Sandbox Code Playgroud)

但是当我尝试执行查询时,我得到:

Caused by: org.hibernate.UnknownEntityTypeException: Unable to locate persister: org.rest.api.server.repository.Terminals
10:28:27,539 …
Run Code Online (Sandbox Code Playgroud)

java spring jpa spring-data-jpa

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

没有正确计算到JSF页面的分页

我想实现本教程中的代码

我用14行数据填充了Oracle表,但是当我每次第二页为空时尝试在JSF页面之间导航时:

在此输入图像描述

在此输入图像描述

这是JSF页面的代码:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"    
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets">
    <h:head>
        <ui:insert name="header">           
            <ui:include src="header.xhtml"/>         
        </ui:insert>
    </h:head>
    <h:body>

        <h1><img src="resources/css/images/icon.png" alt="NVIDIA.com" /> History Center</h1>
        <!-- layer for black background of the buttons -->
        <div id="toolbar" style="margin: 0 auto; width:1180px; height:30px; position:relative;  background-color:black">
            <!-- Include page Navigation -->
            <ui:insert name="Navigation">           
                <ui:include src="Navigation.xhtml"/>         
            </ui:insert>

        </div>  

        <div id="greenBand" class="ui-state-default ui-corner-allh" style="position:relative; top:35px; left:0px;"> 
            <h:graphicImage alt="Dashboard"  style="position:relative; top:-20px; left:9px;"  value="resources/images/logo_sessions.png" …
Run Code Online (Sandbox Code Playgroud)

java sql jsf jsf-2

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

使用Maven构建JavaFX 8

我测试了使用Netbeans 7.4创建JavaFX 8项目.但遗憾的是没有运气.这是POM文件:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.dx57dc</groupId>
    <artifactId>JFX8M</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>

    <name>JFX8M</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <mainClass>com.dx57dc.jfx8m.MainApp</mainClass>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.8</version>
                <executions>
                    <execution>
                        <id>unpack-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>unpack-dependencies</goal>
                        </goals>
                        <configuration>
                            <excludeScope>system</excludeScope>
                            <excludeGroupIds>junit,org.mockito,org.hamcrest</excludeGroupIds>
                            <outputDirectory>${project.build.directory}/classes</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.2.1</version>
                <executions>
                    <execution>
                        <id>unpack-dependencies</id>

                        <phase>package</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>${java.home}/../bin/javafxpackager</executable>
                            <arguments>
                                <argument>-createjar</argument>
                                <argument>-nocss2bin</argument>
                                <argument>-appclass</argument>
                                <argument>${mainClass}</argument>
                                <argument>-srcdir</argument>
                                <argument>${project.build.directory}/classes</argument>
                                <argument>-outdir</argument>
                                <argument>${project.build.directory}</argument>
                                <argument>-outfile</argument>
                                <argument>${project.build.finalName}.jar</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>  
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <compilerArguments>
                        <bootclasspath>${sun.boot.class.path}${path.separator}${java.home}/lib/jfxrt.jar</bootclasspath> …
Run Code Online (Sandbox Code Playgroud)

maven-plugin maven-3 maven javafx-8

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

将展开动画添加到TreeView

我有TreeView的这个例子:

在此输入图像描述

import java.util.Arrays;
import java.util.List;
import javafx.application.Application;
import javafx.beans.property.SimpleStringProperty;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.TextField;
import javafx.scene.control.TreeCell;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeView;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.util.Callback;

public class MainApp extends Application
{

    //private final Node rootIcon = new ImageView(new Image(getClass().getResourceAsStream("picture.png")));
    //private final Image depIcon = new Image(getClass().getResourceAsStream("picture.png"));
    List<Employee> employees = Arrays.<Employee>asList(
        new Employee("Ethan Williams", "Sales Department"),
        new Employee("Emma Jones", "Sales Department"),
        new Employee("Michael Brown", "Sales Department"),
        new Employee("Anna Black", "Sales Department"),
        new Employee("Rodger …
Run Code Online (Sandbox Code Playgroud)

javafx javafx-2 javafx-8

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

微调控制值

我从8u40b17开始使用Spinner.

SpinnerValueFactory svf = new SpinnerValueFactory.IntegerSpinnerValueFactory(0, 100);

Spinner sp = new Spinner();
sp.setValueFactory(svf);
sp.setEditable(true);
sp.setPrefWidth(80);
Run Code Online (Sandbox Code Playgroud)

我注意到当我从键盘输入一些值并且我增加了上限值时,预期的数字不是下一个.而不是这个,它是下一个默认值.我怎么解决这个问题?

例如:如果我有5作为默认值而我输入34,那么按下我希望得到35的上箭头实际得到6.

javafx javafx-8

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

在JPA中重写查询

我想在JPA中重写这个SQL查询.

String hql = "SELECT date(created_at) AS cdate, sum(amount) AS amount, count(id) AS nooftransaction "
                + "FROM payment_transactions WHERE date(created_at)>=date(now()- interval 10 DAY) "
                + "AND date(created_at)<date(now()) GROUP BY date(created_at)";

        TypedQuery<Merchants> query = entityManager.createQuery(hql, Merchants.class);
        List<Merchants> merchants = query.getResultList();
Run Code Online (Sandbox Code Playgroud)

有没有办法将查询重写为JPA,或者我应该按原样使用它?

jpa jpa-2.0 spring-data-jpa

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

从Java HashMap显示Angular下拉列表

我想使用Spring Application的GET请求在Angular应用程序中显示HashMap.我试过这个:

春天代码:

@GetMapping("gateways")
public ResponseEntity<?> getGateways() {
    Map<Integer, String> list = new HashMap<>();
    list.put(1, "Bogus");
    return ok(list.put);
}
Run Code Online (Sandbox Code Playgroud)

角度服务:

getContractGatewaysList(): Observable<Array<ContractGatewaysList>> {
    return this.http.get<Array<ContractGatewaysList>>(environment.api.urls.contracts.getContractGateways);
  }
Run Code Online (Sandbox Code Playgroud)

角度成分:

gateways: ContractGatewaysList[];

this.contractService.getContractGatewaysList()
      .subscribe(value => {
        if (value != null) {
          this.gateways = value;
        }
      });
Run Code Online (Sandbox Code Playgroud)

接口:

export interface ContractGatewaysList {
  id: number;
  name: string;
}
Run Code Online (Sandbox Code Playgroud)

HTML代码:

<div class="form-group gateway">
    <div class="input-group-prepend">
      <label for="merchant_id">Gateway</label>
    </div>
    <select class="custom-select" name="gateway" [(ngModel)]="contract.gateway" id="gateway" required>
      <option selected>Please Select...</option>
      <option [value]="gateway.id" *ngFor="let gateway of gateways">{{ gateway.name }}</option>
    </select> …
Run Code Online (Sandbox Code Playgroud)

spring typescript angular angular6

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

从 MultiValueMap 获取值

我使用以下代码从 HTTP 请求获取值:

@PostMapping(consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, value = "/v1/notification")
  public ResponseEntity<String> handleNotifications(@RequestBody MultiValueMap<String, Object> keyValuePairs) {

    LOGGER.debug("handleFormMessage");
    LOGGER.debug("keyValuePairs: {}", keyValuePairs);

    String unique_id = String.valueOf(keyValuePairs.get("unique_id"));

    System.out.println("!!!!!!!!!!!!!! ! unique_id " + unique_id);
}
Run Code Online (Sandbox Code Playgroud)

但我得到这个值:!!!!!!!!!!!!!! ! unique_id [24q376c3ts2kh3o3220rry322dfe2k7y]

[]有没有办法在没有经典的情况下从字符串中删除String result = str.substring(0, index) + str.substring(index+1);

有没有办法获取值?

我用它来发布值:

在此输入图像描述

java spring-boot spring-restcontroller spring-rest

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

将 WHERE IN 子句添加到 JPA 规范

我正在尝试实现受 IN 子句限制的搜索功能:

我想实现带有过滤器限制的搜索实现:

    @GetMapping("find")
    public Page<MerchantUserDTO> getAllBySpecification(
            @And({
                @Spec(path = "name", spec = LikeIgnoreCase.class),
                @Spec(path = "login", spec = LikeIgnoreCase.class),
                @Spec(path = "email", spec = LikeIgnoreCase.class),
            }) Specification<Users> specification,
            @SortDefault(sort = "login", direction = Sort.Direction.DESC) Pageable pageable
    ) {        
        return merchantUserService.getAllBySpecification(specification, pageable)
                .map(g -> MerchantUserDTO.builder()                   
                        .id(g.getId())
                        .login(g.getLogin())                        
                        .build()
                );
    }

    @Override
    public Page<Users> getAllBySpecification(Specification<Users> specification, Pageable pageable) {
        return dao.findAllByTypeIn(specification, pageable, "MerchantUser");
    }
Run Code Online (Sandbox Code Playgroud)

存储库:

@Repository
public interface MerchantUserRepository extends JpaRepository<Users, Integer>, JpaSpecificationExecutor<Users> {

    Page<Users> findAllByTypeIn(Pageable page, String... types);

    Page<Users> …
Run Code Online (Sandbox Code Playgroud)

jpa jpa-2.0 spring-data-jpa jpa-2.1 spring-boot

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

使用Spring和Specification-arg-resolver实现查找全部

我想用Specification-arg-resolver和Spring实现Angular的所有功能。

我正在尝试发送此网址:

[HPM] GET /api/be/find?name=tes&login=tes&allowed_ip_address=tes&page=0&size=10
Run Code Online (Sandbox Code Playgroud)

通过spec -arg-resolver实现

public Page<BeDTO> getAllBySpecification(
            @And({
                @Spec(path = "name", spec = LikeIgnoreCase.class),
                @Spec(path = "login", spec = LikeIgnoreCase.class),
                @Spec(path = "allowed_ip_address", spec = LikeIgnoreCase.class)
        }) Specification<Be> specification,
        Pageable pageable
    ) {        
        return merchantService.getAllBySpecification(specification, pageable)
Run Code Online (Sandbox Code Playgroud)

当我送参数有关name,以login它的正常工作。

但是,当我发送所有3个参数来实现All搜索功能时,我什么也没得到。看来我需要一些不同的规格配置。

您知道为什么它无法正常工作吗?

进入日志,我得到:

select * from merchants merchants0_ where (upper(merchants0_.name) like ?) and (upper(merchants0_.login) like ?) and (upper(merchants0_.allowed_ip_address) like ?) limit ?
Run Code Online (Sandbox Code Playgroud)

java spring jpa-2.0 spring-data-jpa spring-boot

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