我想在 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) 我想实现本教程中的代码
我用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) 我测试了使用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) 我有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) 我从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.
我想在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,或者我应该按原样使用它?
我想使用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) 我使用以下代码从 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);?
有没有办法获取值?
我用它来发布值:
我正在尝试实现受 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) 我想用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 ×4
javafx-8 ×3
jpa ×3
jpa-2.0 ×3
spring ×3
spring-boot ×3
javafx ×2
angular ×1
angular6 ×1
javafx-2 ×1
jpa-2.1 ×1
jsf ×1
jsf-2 ×1
maven ×1
maven-3 ×1
maven-plugin ×1
spring-rest ×1
sql ×1
typescript ×1