小编Rob*_*t H的帖子

找到Java标准库

找到包含核心Java类的jar的最佳方法是java.lang.Object什么?我一直在使用JAVA_HOME,但事实证明只有安装了JDK才能使用.如何java从命令行运行时,如何找到将使用的标准库位置?

另外,我需要从Python脚本执行此操作,因此请不要使用Java库进行响应.

python java classpath

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

进行本地连接时,不允许主机连接到此mysql服务器

当我尝试连接putty时,我得到'host不允许连接到这个mysql服务器'.为什么会这样?主机和客户端都在我的机器上.

当我连接命令行时,它连接.

mysql database putty

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

应用程序无法启动Springboot RC2

从弹簧启动RC1升级到弹簧启动RC2正在打破多个项目的构建.我决定在提出问题之前在这里发帖.我们查看了发行说明,并没有看到除了执行器配置之外我们需要进行的任何更改.

看看这个提交,似乎需要一个新的Milestone版本的Spring云流需要https://github.com/spring-cloud/spring-cloud-commons/commit/43ea0461ee16e1ee6f250ece8c82f323f2aef2ae

使用这些版本

kotlinVersion=1.2.21
springBootVersion=2.0.0.RC2
springCloudVersion=Finchley.M6
springCloudStreamsVersion=Elmhurst.M4
Run Code Online (Sandbox Code Playgroud)

我们收到了这个错误

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configurationPropertiesBeans' defined in org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.context.properties.ConfigurationPropertiesBeans]: Factory method 'configurationPropertiesBeans' threw exception; nested exception is java.lang.NoSuchFieldError: BINDER_BEAN_NAME
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:587) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1250) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1099) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:205) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:238) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:709) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:534) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at …
Run Code Online (Sandbox Code Playgroud)

spring-boot spring-cloud

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

有没有可以将C# Linq语句转换为java的工具?

我知道 Java 没有 LINQ 等效项,但是有没有一个工具(最好是免费的)可以就如何将 C# LINQ 语句转换为 Java 语句提出建议?

这个问题的目的不是寻找LINQ 的替代品,而是寻找一个可以就如何将 LINQ 语句转换为 Java 语句提出建议的工具。

对替代方案的讨论已经在 SO 上被讨论得一塌糊涂,SO 不需要另一个与替代方案相关的问题。然而,在我的研究中,我找不到任何提及可以简化 LINQ 到 Java 过渡的工具。

java linq

5
推荐指数
0
解决办法
246
查看次数

如何使一系列非数据库方法模仿事务。

我需要执行几个需要“事务处理”的方法调用,但是除了try / catch / finally外,我不确定如何实现此方法。

背景

  • 应用程序是基于控制台的。
  • 应用程序将有多个线程
  • 查询数据库以获取连接信息,建立与Web服务的连接以登录,生成会话ID并更新数据库。
  • 一个操作将调用注销,该注销需要清理数据库,清除会话ID并注销Web服务。

我想弄清楚的是

我想确保当请求注销时,我想确保整个过程要么全部成功,要么根本没有成功。例如,我不希望清理数据库,清理会话ID和注销操作失败(因此登录仍然有效)。

理想情况下,解决方案将在发生故障时“回滚”,从而确保维持先前的状态。

是否有一种巧妙的方法可以完成此操作,还是我受困于一系列嵌套的try / catch / finally块来执行此操作?

java transactions

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

从线程创建其他线程的最有效方法是什么?

从线程创建其他线程的最有效方法是什么?

上下文

我正在重新设计一个更高效的应用程序.最大的改进之一是运行并发操作; 但我不熟悉并发编程.我希望改进的方案如下:

我们有多个市场可以从中导入订单,然后上传到我们的ERP系统.每个市场都有多种记录类型可供导入.目前,这MP->RT->RT->RT->RTMP调用marketplace()的位置一样,并且添加了后续的recordtypes(RT).

我想要实现的是如下流程:

MP 
  |-> RT
  |-> RT
  |-> RT
  |-> RT
MP
  |-> RT
  |-> RT
  ...
Run Code Online (Sandbox Code Playgroud)

调用多个市场的地方,然后同时添加多个记录类型.

我目前正在使用一个executor service控制MP任务,但我想知道处理RT任务的最佳方法.

java concurrency multithreading thread-safety executorservice

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

为什么我的JDBC更新不起作用?

我一直在从PostgreSQL 9.1迁移到Oracle 11gR2,并遇到了一个奇怪的问题.

当客户被添加到我们的ERP系统时,我一直在运行更新表的代码.自3月以来,此代码一直在PostgreSQL上运行,没有任何问题.现在我正在切换到Oracle,相同的代码不再更新.

原始代码

update = "UPDATE store SET added_customer = 'y' WHERE order_id = ?";
try {
    PreparedStatement pStmnt = getConn().prepareStatement(update);
    pStmnt.setString(1, orderId);               
    results = pStmnt.executeUpdate();

    if (results > 0) {
        added = true;                   
    }       
} catch (SQLException ex) {
    LOGGER.error(ex.toString());
}
Run Code Online (Sandbox Code Playgroud)

没有抛出任何异常,但没有数据发生变化,所以我认为"自动提交一定不能正常工作,让我们手动提交":

新规范

update = "UPDATE shop_ca_orders SET added_customer = 'y' WHERE order_id = ?";
try {                 
    getConn().setAutoCommit(false); //Added
    PreparedStatement pStmnt = getConn().prepareStatement(update);
    pStmnt.setString(1, orderId);               
    results = pStmnt.executeUpdate();

    if (results > 0) {
        added = true;
        getConn().commit(); …
Run Code Online (Sandbox Code Playgroud)

java oracle jdbc

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

使用 spring boot 在后台运行进程

如何使用 Spring Boot 在后台运行某些进程?这是我需要的一个例子:

@SpringBootApplication
public class SpringMySqlApplication {

    @Autowired
    AppUsersRepo appRepo;

    public static void main(String[] args) {
        SpringApplication.run(SpringMySqlApplication.class, args);

        while (true) {
            Date date = new Date();
            System.out.println(date.toString());
            try {
                TimeUnit.SECONDS.sleep(3);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

java spring-boot workmanagertaskexecutor

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

Spring Data,多个数据源,不是托管类型异常

我一直在尝试让多个数据库系统在同一个 Spring Boot 项目中工作的时间比应有的时间长。我不断遇到以下异常,需要更多的目光来推动我解决问题。

我对下面的代码量表示歉意,但是由于我不确定问题实际发生在哪里,所以我在下面列出了所有内容。

需要注意的是:我使用专有 ERP 数据库作为端点之一。该端点是 Oracle 数据库并且是只读的。如果需要,我们可以将其切换到 MySQL 端点,但是我的用例需要 ERP 的端点才能使项目成功。

使用的资源:

我确信我的答案可能仍然存在于上述之一中,但是我现在太接近问题了,这就是我需要帮助的地方。

例外:

java.lang.IllegalArgumentException: Not a managed type: class com.xxx.ddbo.suiteanalytics.objects.ReturnsReasonBrand
Run Code Online (Sandbox Code Playgroud)

代码:

application.properties

    #Global properties for spring configuration
    logging.level.org.apache=ERROR      
    logging.level.org.springframework=WARN
    logging.level.org.hibernate=INFO        
    logging.level.org.hibernate.type=INFO

    #Spring configuration
    spring.jpa.show-sql=true
    spring.jackson.property-naming-strategy=CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES
    spring.jpa.hibernate.naming.strategy=org.hibernate.cfg.ImprovedNamingStrategy
    spring.jpa.properties.hibernate.show_sql=false
    spring.jpa.properties.hibernate.use_sql_comments=true
    spring.jpa.properties.hibernate.format_sql=true
    spring.jpa.properties.hibernate.type=info
    spring.jpa.generate-ddl=false
    spring.jpa.database=default


    ## DATABASE CONFIGURATIONS

    #Properties for PostgreSQL connection
    spring.postgresql.datasource.url=xxxxxxxx
    spring.postgresql.datasource.username=xxxxxxxx
    spring.postgresql.datasource.password=xxxxxxxx
    spring.postgresql.datasource.driver-class-name=org.postgresql.Driver
    spring.postgresql.datasource.tomcat.max-active=50

    #Properties for NetSuite SuiteAnalytics ODBC connection
    #Sandbox URL
    spring.suiteanalytics.datasource.url=xxxxxxxx
    #Production URL
    #spring.suiteanalytics.datasource.url=xxxxxxxx
    spring.suiteanalytics.datasource.username=xxxxxxxx …
Run Code Online (Sandbox Code Playgroud)

java postgresql spring netsuite spring-boot

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

比较if:!string.equals("")vs!""中的字符串.equals(string)

可能重复:
这两个条件之间的差异?

我正在做一些代码清理,NetBeans提出了改变的建议

if(!billAddress1.equals(""))if (!"".equals(billAddress1)).

两者之间有什么区别,以及使用建议版本优于原始版本的可读性的优势?

java

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