小编Har*_*ara的帖子

MongoDB:javascript执行失败:无法在src/mongo/shell/collection.js中保存DBQuery对象

在MongoDb中,当我尝试修改集合中的现有文档时,它会生成以下异常: javascript execution failed : can't save a DBQuery object at src/mongo/shell/collection.js

在mongoDb shell中,我执行以下操作:

 > var doc1 = db.users.find({name:"Harmeet"})
 > doc1.color = "Blue"
 > db.users.save(doc1)
Run Code Online (Sandbox Code Playgroud)

当调用save方法时异常thow.

javascript exception mongodb

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

Apache Spark 2.0:java.lang.UnsupportedOperationException:找不到java.time.LocalDate的编码器

我正在使用Apache Spark 2.0并创建case class提供架构DetaSet.当我试图根据如何在数据集中存储自定义对象来定义自定义编码器因为java.time.LocalDate我得到以下例外:

java.lang.UnsupportedOperationException: No Encoder found for java.time.LocalDate
- field (class: "java.time.LocalDate", name: "callDate")
- root class: "FireService"
at org.apache.spark.sql.catalyst.ScalaReflection$.org$apache$spark$sql$catalyst$ScalaReflection$$serializerFor(ScalaReflection.scala:598)
at org.apache.spark.sql.catalyst.ScalaReflection$$anonfun$9.apply(ScalaReflection.scala:592)
at org.apache.spark.sql.catalyst.ScalaReflection$$anonfun$9.apply(ScalaReflection.scala:583)
at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:241)
at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:241)
at scala.collection.immutable.List.foreach(List.scala:381)
at scala.collection.TraversableLike$class.flatMap(TraversableLike.scala:241)
............
Run Code Online (Sandbox Code Playgroud)

以下是代码:

case class FireService(callNumber: String, callDate: java.time.LocalDate)
implicit val localDateEncoder: org.apache.spark.sql.Encoder[java.time.LocalDate] = org.apache.spark.sql.Encoders.kryo[java.time.LocalDate]

val fireServiceDf = df.map(row => {
val dateFormatter = java.time.format.DateTimeFormatter.ofPattern("MM/dd /yyyy")
FireService(row.getAs[String](0),  java.time.LocalDate.parse(row.getAs[String](4), dateFormatter))
})
Run Code Online (Sandbox Code Playgroud)

我们如何定义第三方api的spark编码器?

更新

当我为整个案例类创建编码器时,df.map..将对象映射为二进制,如下所示:

implicit val …
Run Code Online (Sandbox Code Playgroud)

scala apache-spark apache-spark-sql apache-spark-dataset apache-spark-encoders

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

Java 8:方法引用Bound Receiver和UnBound Receiver之间的区别

我试图在我的代码中使用Java 8方法引用.有四种类型的方法参考可用.

  1. 静态方法参考.
  2. 实例方法(绑定接收器).
  3. 实例方法(UnBound接收器).
  4. 构造函数引用.

随着Static method referenceConstructor reference我有没有问题,但Instance Method (Bound receiver)Instance Method (UnBound receiver)真搞糊涂了.在Bound接收器中,我们使用Object引用变量来调用方法,如:

objectRef::Instance Method
Run Code Online (Sandbox Code Playgroud)

UnBound接收器中,我们使用类名来调用方法,如:

ClassName::Instance Method.
Run Code Online (Sandbox Code Playgroud)

我有以下问题:

  1. 实例方法的不同类型的方法引用需要什么?
  2. BoundUnbound接收方法引用有什么区别?
  3. 我们应该Bound在哪里使用Unbound接收器?我们应该在哪里使

我还从Java 8语言特性书中找到了解释BoundUnbound接收器,但仍然与实际概念混淆.

java lambda java-8 method-reference

10
推荐指数
2
解决办法
4034
查看次数

为什么不推荐使用buildSessionFactory()?

为什么被buildSessionFactory()取代buildSessionFactory(ServiceRegistry)?ServiceRegistry的重要性是什么?

java hibernate

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

Thymeleaf:使用#dates.format()函数进行国际化格式化日期.

Thymeleaf #dates.format()在视图层使用格式日期功能.我为pic创建了一个internatinalization属性文件的日期格式.我正在使用这样的#dates.format(date, (#{app.dateformat}))功能.但Thymeleaf抛出一个解析异常.因为百里香现在解决了app.dateformat.我如何在百里香中使用日期格式国际化方式.以下是一个例外:

org.springframework.expression.spel.SpelParseException: EL1043E:(pos 37): Unexpected token. Expected 'identifier' but was 'lcurly({)'
Run Code Online (Sandbox Code Playgroud)

java spring-mvc thymeleaf

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

Jboss Hibernate工具:读取错误模式 - 可能是JDBC驱动程序问题

您好我正在尝试使用JBoss Hibernate Tools进行逆向工程.我正在使用eclipse luna来自eclipse市场的最新hibernate jboss工具.当我尝试配置hibernate工具配置时,配置完成后,当我展开树并展开database节点时,它会生成以下错误:

<Reading Schema Error: Could not get list of suggested identity strategies from database. Probably a JDBC Driver Problem>
Run Code Online (Sandbox Code Playgroud)

堆栈跟踪:

org.hibernate.exception.SQLGrammarException: Could not get list of suggested identity strategies from database. Probably a JDBC driver problem. 
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:92)
at org.hibernate.cfg.reveng.dialect.MySQLMetaDataDialect.getSuggestedPrimaryKeyStrategyName(MySQLMetaDataDialect.java:55)
at org.hibernate.cfg.reveng.JDBCReader.processPrimaryKey(JDBCReader.java:429)
at org.hibernate.cfg.reveng.JDBCReader.readDatabaseSchema(JDBCReader.java:86)
at org.hibernate.eclipse.console.workbench.LazyDatabaseSchemaWorkbenchAdapter$2.execute(LazyDatabaseSchemaWorkbenchAdapter.java:126)
at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:63)
at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:107)
at org.hibernate.eclipse.console.workbench.LazyDatabaseSchemaWorkbenchAdapter.readDatabaseSchema(LazyDatabaseSchemaWorkbenchAdapter.java:115)
at org.hibernate.eclipse.console.workbench.LazyDatabaseSchemaWorkbenchAdapter.getChildren(LazyDatabaseSchemaWorkbenchAdapter.java:65)
at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.fetchDeferredChildren(BasicWorkbenchAdapter.java:106)
at org.eclipse.ui.progress.DeferredTreeContentManager$1.run(DeferredTreeContentManager.java:238)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check …
Run Code Online (Sandbox Code Playgroud)

java jboss hibernate reverse-engineering

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

Thymeleaf:在 thymeleaf 中创建动态 URL 查询字符串

我是 thymeleaf 的新手,我想使用 thymeleaf url 创建动态查询字符串。对于分页,我使用通用片段并在所有页面中包含片段。所有页面都有搜索选项,搜索时也需要分页。因此,我们需要在分页中传递动态查询字符串作为搜索条件。但是当我动态创建查询字符串时,URL 编码特殊字符,如=&。以下是我的代码

<!-- Pagination Bar -->
<div th:fragment='paginationbar(searchArguments)'>
  <div class='pagination pagination-centered'>
    <ul>
      <li th:class="${page.firstPage}? 'disabled' : ''">
        <span th:if='${page.firstPage}'> First</span>
        <a th:if='${not page.firstPage}' th:href='@{${page.url}(page=0,size=${page.size},${searchArguments})}'>First</a>
      </li>
      <li th:class="${page.hasPreviousPage}? '' : 'disabled'">
        <span th:if='${not page.hasPreviousPage}'>&lt;&lt;</span>
        <a th:if='${page.hasPreviousPage}' th:href='@{${page.url}(page=${page.currentNumber - 2},size=${page.size},${searchArguments})}' title='Go to previous page'>&lt;&lt;</a>
      </li>
       <li th:each='item : ${page.items}' th:class="${item.current}? 'active' : ''">
        <span th:if='${item.current}' th:text='${item.number}'>1</span>
        <a th:if='${not item.current}' th:href='@{${page.url}(page=${item.number - 1},size=${page.size},${searchArguments})}'><span th:text='${item.number}'>1</span></a>
      </li> 
      <li th:class="${page.hasNextPage}? '' : 'disabled'">
        <span th:if='${not page.hasNextPage}'>&gt;&gt;</span>
        <a …
Run Code Online (Sandbox Code Playgroud)

java spring-mvc urlencode thymeleaf

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

java 9:JLink创建了无效图像 - 缺少模块可执行脚本

我创建3个模块的一个示例应用程序user,deptaccount.在我的用户模块中,我有一个主类,并使用以下命令编译我的模块:

javac -d target --module-source-path src $(find -name "*.java")
Run Code Online (Sandbox Code Playgroud)

编译后,执行以下命令运行:

java -p target -m com.user/com.user.info.Launcher
Run Code Online (Sandbox Code Playgroud)

运行java模块后的输出成功.但是当尝试使用jlink成功创建的映像创建运行时映像但模块可执行脚本不存在时.为了创建图像,我使用以下命令:

jlink --module-path $JAVA_HOME/jmods:target --add-modules com.user --output my-app
Run Code Online (Sandbox Code Playgroud)

在,运行时映像,我有bin目录,但这个目录只包含javakeynote脚本.我期待用户主类脚本,以执行我的应用程序.

我的Java版本如下:

java version "9-ea"
Java(TM) SE Runtime Environment (build 9-ea+165)
Java HotSpot(TM) 64-Bit Server VM (build 9-ea+165, mixed mode)
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个问题?

java jlink java-9 java-module

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

Thymeleaf:如何在使用Thymeleaf的JavaScript中使用布尔运算符

我在javascript使用中使用thymeleaf,th:inline="javascript"但是当我们在java脚本中添加布尔条件时,thymeleaf会出现如下异常:

org.xml.sax.SAXParseException; lineNumber: 14; columnNumber: 22; The entity name must immediately follow the '&' in the entity reference.
com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203)
com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177)
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:441)
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:368)
com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1436)
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEntityReference(XMLDocumentFragmentScannerImpl.java:1845)
.............................
Run Code Online (Sandbox Code Playgroud)

以下是我的javascript代码:

<script type="text/javascript" th:inline="javascript">
    $(document).ready(function(){
        $('.fancybox').fancybox({
            'width' :'623px',
            'maxHeight':'156px'
        });

        var catId = $("#category").val();
        if(catId != null && catId != ''){
            findSubCategories();
            /*<![CDATA[*/
                var subCatId = /*[[${searchProductDto.subCategory}]]*/
            /*]]>*/
            debugger;
            if(subCatId != null){
                $("#subCategory").val(subCatId);
            }
        }
    });
...............................
Run Code Online (Sandbox Code Playgroud)

我们如何在百里香中使用&操作员?

javascript java exception thymeleaf

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

Quartz Scheduler:java.lang.IllegalStateException:JobStore 已关闭 - 正在中止重试

我将 JDBC 作业存储与quartz 一起使用,因为在集群环境中管理作业。以下是我使用mysql的jdbc配置:

    #============================================================================
# Configure Main Scheduler Properties
#============================================================================

org.quartz.scheduler.instanceName: MyScheduler
org.quartz.scheduler.instanceId: instance_one

org.quartz.scheduler.skipUpdateCheck: true


#============================================================================
# Configure ThreadPool
#============================================================================

org.quartz.threadPool.class: org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount: 5
org.quartz.threadPool.threadPriority: 5

#============================================================================
# Configure JobStore
#============================================================================

org.quartz.jobStore.misfireThreshold = 60000

org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.StdJDBCDelegate
org.quartz.jobStore.useProperties = false
org.quartz.jobStore.dataSource = quartz_cluster
org.quartz.jobStore.tablePrefix = QRTZ_
org.quartz.jobStore.isClustered = true


#============================================================================
# Configure Datasources
#============================================================================

org.quartz.dataSource.quartz_cluster.driver = com.mysql.cj.jdbc.Driver
org.quartz.dataSource.quartz_cluster.URL = jdbc:mysql://localhost:3306/quartz_cluster
org.quartz.dataSource.quartz_cluster.user = root
org.quartz.dataSource.quartz_cluster.password = root
org.quartz.dataSource.quartz_cluster.maxConnections = 5
Run Code Online (Sandbox Code Playgroud)

每当我运行具有上述属性的夸脱时,我的作业就会开始执行,执行 4 次后,我会收到以下异常:

[ERROR] - [2016-09-15 …
Run Code Online (Sandbox Code Playgroud)

java mysql exception quartz-scheduler crontrigger

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