我正在创建一个Spring应用程序,并且需要与Wikipedia集成。特别是,我想从一组给定的(大型)城市中提取数据,例如国家,网站和坐标。
我试图了解哪些库或框架可能有用,但是我要处理的主要问题是我想从中提取信息的页面没有引用结构。主要问题不是缺少某些信息,这是完全可以接受的,而是城市代表权在不同城市之间变化。例如,DBPedia本体(例如http://dbpedia.org/ontology/City)不能反映出我可以通过SPARQL查询从dbpedia.org/sparql中提取的内容。这样,我不知道如何系统地提取我需要的数据(即整个数据集)。
有什么技术可以支持我在一组预定义的城市中提取数据的任务?
一种解决方案是进行某种自然语言处理,以便在整个Wikipedia页面上查找所需的信息,但是如果我必须自己编写,则需要大量的精力。另一种解决方案是利用结构化数据源,该结构化数据源为我预处理了Wikipedia,并为所包含的信息提供了某种结构,但我找不到。在第三个解决方案上,可能尝试对Wikipedia进行不同的查询,但是我无法找到一种通过这些Wikipedia API提取所需信息的方法。
以下applicationContext.xml没有发出任何警告,导致恶意异常.阅读旧线程没有帮助.例外的主要部分是
cvc-complex-type.2.4.c:匹配的通配符是strict,但是没有为元素jpa:repositories找到声明.
这是applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">
<context:property-placeholder location="classpath*:spring/*.properties" />
<context:component-scan base-package="com.lh.clte" />
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="${database.driverClassName}" />
<property name="url" value="${database.url}" />
<property name="username" value="${database.username}" />
<property name="password" value="${database.password}" />
<property name="initialSize" value="3" />
<property name="maxActive" value="10" />
</bean>
<tx:annotation-driven mode="proxy"
transaction-manager="transactionManager" />
<bean class="org.springframework.orm.jpa.JpaTransactionManager"
id="transactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<bean
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
id="entityManagerFactory">
<property name="persistenceUnitName" value="persistenceUnit" />
<property name="dataSource" …Run Code Online (Sandbox Code Playgroud) 我有一个Spring实体,其中有一个用@NotNull注释的字段来自javax.validation.constraints
@Entity
public abstract class IdentifiableNamedEntity {
@NotNull
@Column(unique = true)
private String name;
}
Run Code Online (Sandbox Code Playgroud)
问题是如果为name字段设置null值,它将存储在数据库中.但是,如果我按照以下方式更改类,则会引发我希望收到的异常:
@Entity
public abstract class IdentifiableNamedEntity {
@Column(unique = true, nullable=false)
private String name;
}
Run Code Online (Sandbox Code Playgroud)
有没有办法可以避免指定nullable = false,但让@NotNull按照我的意愿行事?是否有任何替代nullable = false依赖于标准Java注释,例如一些Hibernate配置?
这是我的弹簧配置:
的ApplicationContext
<beans ...>
<context:property-placeholder location="classpath*:spring/database.properties" />
<context:component-scan base-package="com.lh.clte" />
<import resource="classpath:spring/applicationContext-persistence.xml" />
</beans>
Run Code Online (Sandbox Code Playgroud)
的applicationContext持久性
<beans ...>
<import resource="classpath:spring/applicationContext-jpa.xml" />
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="${database.driverClassName}" />
<property name="url" value="${database.url}" />
<property name="username" value="${database.username}" />
<property name="password" value="${database.password}" />
<property name="initialSize" value="3" />
<property …Run Code Online (Sandbox Code Playgroud) 我试图从我的数据库中删除大量的记录.每个记录都有一个外键级联,这样,当通过JPA一次删除一条记录时,每次删除需要大约5秒.
所以我决定写一个像这样的JPQL查询:
@Repository
public interface MyTableRepository extends JpaRepository<MyTable, Long> {
@Query("delete from MyTable where id in :ids")
void deleteAllIds(@Param("ids") Long[] ids);
}
Run Code Online (Sandbox Code Playgroud)
当我运行它或等效时void deleteAllIds(@Param("ids") Set<Long> ids);,我得到以下内容:
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessApiUsageException: org.hibernate.hql.internal.QueryExecutionRequestException: Not supported for DML operations [delete from com.lh.clte.domain.content.business.Hotel where id in (:ids_0_, :ids_1_, :ids_2_, :ids_3_, ... for the entire array size)]
org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:293)
org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:403)
org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:59)
org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213)
org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:147)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodIntercceptor.invoke(CrudMethodMetadataPostProcessor.java:111)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
com.sun.proxy.$Proxy72.deleteAllId(Unknown Source)
Run Code Online (Sandbox Code Playgroud)
我怎样才能实现目标?
我准备了这个脚本来尝试使用不同的参数多次并行执行相同的函数:
$myparams = "A", "B","C", "D"
$doPlan = {
Param([string] $myparam)
echo "print $myparam"
# MakeARestCall is a function calling a web service
MakeARestCall -myparam $myparam
echo "done"
}
$myparams | Foreach-Object {
Start-Job -ScriptBlock $doPlan -ArgumentList $_
}
Run Code Online (Sandbox Code Playgroud)
当我运行它时,输出是
Id Name PSJobTypeName State HasMoreData Location Command
-- ---- ------------- ----- ----------- -------- -------
79 Job79 BackgroundJob Running True localhost ...
81 Job81 BackgroundJob Running True localhost ...
83 Job83 BackgroundJob Running True localhost ...
85 Job85 BackgroundJob Running True …Run Code Online (Sandbox Code Playgroud) 我正在尝试居中跨越GridPane的两列的标签。但是,它似乎不起作用。
应用类别:
public class GUIMainFXML extends Application {
@Override
public void start(Stage primaryStage) {
try {
GridPane p = (GridPane) FXMLLoader.load(getClass().getResource(
"FirstGUIexample.fxml"));
Scene scene = new Scene(p);
scene.getStylesheets().add(
getClass().getResource("application.css").toExternalForm());
primaryStage.setTitle("Welcome (FXML CODE)");
primaryStage.setScene(scene);
primaryStage.show();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
launch(args);
}}
Run Code Online (Sandbox Code Playgroud)
fxml文件:
<GridPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"
hgap="5" vgap="5">
<padding>
<Insets top="10" right="10" bottom="10" left="10" />
</padding>
<children>
<Text text="Welcome" GridPane.columnSpan="2" GridPane.halignment="CENTER"
GridPane.rowIndex="0" />
<Button text="Press me" GridPane.halignment="CENTER"
GridPane.rowIndex="1" GridPane.columnSpan="2" />
<CheckBox …Run Code Online (Sandbox Code Playgroud) 我试图使用REST API进行简单的往返,导致将实体存储到数据库中,然后返回存储的实体.向下工作正常,实体存储并正确返回到REST控制器.但是,当我返回时,杰克逊似乎错误地序列化,因为"名称"属性不包括在内.
这是实体:
@Entity
@Configurable
public class MyEntity extends IdentifiableEntity {
private String name;
protected MyEntity() {
};
public MyEntity(String name) {
this.name = name;
}
}
Run Code Online (Sandbox Code Playgroud)
和扩展实体:
@Configurable
@Inheritance(strategy = InheritanceType.JOINED)
@Entity
public abstract class IdentifiableEntity {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
private Long id;
@Version
@Column(name = "version")
private Integer version = 1;
public String toString() {
return ReflectionToStringBuilder.toString(this,
ToStringStyle.SHORT_PREFIX_STYLE);
}
public Long getId() {
return this.id;
}
public void setId(Long id) {
this.id = id; …Run Code Online (Sandbox Code Playgroud) 我正在使用 Spring Boot,我正在尝试部署一个非常简单的过程。
我试图把过程定义放置一个名为文件夹中processes的src/main/resources。不确定是否有效,我还尝试手动部署流程定义。
过程是:
<?xml version="1.0" encoding="UTF-8"?>
<definitions
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:activiti="http://activiti.org/bpmn"
targetNamespace="MyProcessesNamespace">
<process id="oneTaskProcess" name="The One Task Process" isExecutable="true">
<startEvent id="theStart" />
<sequenceFlow id="flow1" sourceRef="theStart" targetRef="theTask" />
<userTask id="theTask" name="my task" />
<sequenceFlow id="flow2" sourceRef="theTask" targetRef="theEnd" />
<endEvent id="theEnd" />
</process>
</definitions>
Run Code Online (Sandbox Code Playgroud)
我用来手动部署它的代码是:
DeploymentBuilder db = repositoryService.createDeployment().
name("Deployment name");
Resource processesResource = resourceLoader.getResource("classpath:processes");
File processesFolder = processesResource.getFile();
Collection<File> files =
FileUtils.listFiles(processesFolder, null, false);
for (File f : files) {
InputStream is = new FileInputStream(f);
db.addInputStream(f.getName(), is); …Run Code Online (Sandbox Code Playgroud) 我正在尝试构建从Git存储库导入的Android应用程序.这个相同的应用程序在另一个环境中正确构建,但在我的环境中,我收到以下错误:
Error:(41, 13) Failed to resolve: com.afollestad:material-dialogs:0.7.7.0
Run Code Online (Sandbox Code Playgroud)
我的build.gradle:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 22
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "my.app.id"
minSdkVersion 16
targetSdkVersion 22
multiDexEnabled true
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.2.0' …Run Code Online (Sandbox Code Playgroud) 我正在使用 Bootstrap 轮播,我想垂直居中我用来在轮播中前后滑动的 V 形箭头。目前它们水平居中,但与顶部对齐。
代码:
<div class="row">
<div class="col-md-12">
<div id="Carousel" class="carousel slide">
<ol class="carousel-indicators">
<li data-target="#Carousel" data-slide-to="0" class="active"></li>
<li data-target="#Carousel" data-slide-to="1"></li>
<li data-target="#Carousel" data-slide-to="2"></li>
</ol>
<!-- Carousel items -->
<div class="carousel-inner">
<div class="item active">
<div class="row">
<div class="text-center">
<h1>Header</h1>
<p>Content</p>
</div>
</div><!--.row-->
</div><!--.item-->
</div>
<a data-slide="prev" data-target="#Carousel" href="javascript:;" class="left carousel-control"><i
class="fa fa-chevron-left fa-2x" aria-hidden="true"></i></a>
<a data-slide="next" data-target="#Carousel" href="javascript:;" class="right carousel-control"><i
class="fa fa-chevron-right fa-2x" aria-hidden="true"></i></a>
</div><!--.Carousel-->
</div>
</div>
Run Code Online (Sandbox Code Playgroud) java ×4
spring ×4
jpa ×3
activiti ×1
android ×1
carousel ×1
css ×1
gradle ×1
jackson ×1
javafx ×1
json ×1
notnull ×1
powershell ×1
repository ×1
spring-boot ×1
spring-data ×1
spring-mvc ×1
start-job ×1