小编Ram*_*ash的帖子

Spring应用程序不会在包之外启动

我正在按照教程使用Spring构建一个基本应用程序.只要我遵循这个子目录结构,它就能完美运行:

??? src
    ??? main
        ??? java
            ??? hello
Run Code Online (Sandbox Code Playgroud)

如果我将我的Application.javaScheduledTasks.java类移出hello包,我会收到以下错误:

** WARNING ** : Your ApplicationContext is unlikely to start due to a `@ComponentScan` of the default package.
Run Code Online (Sandbox Code Playgroud)

几秒钟后,确实......

java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: org.springframework.context.annotation.AnnotationConfigApplicationContext@71fa8894: startup date [Wed Jan 18 22:19:12 CET 2017]; root of context hierarchy
Run Code Online (Sandbox Code Playgroud)

我的问题是,为什么我需要将我的课程放入包中?它有什么用?我怎样才能避免这个错误?如果它是一个非常简单的应用程序,我真的需要使用包吗?

java spring

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

递归方法调用在 kotlin 中导致 StackOverFlowError 但在 java 中不会

我在 java 和 kotlin 中有两个几乎相同的代码

爪哇:

public void reverseString(char[] s) {
    helper(s, 0, s.length - 1);
}

public void helper(char[] s, int left, int right) {
    if (left >= right) return;
    char tmp = s[left];
    s[left++] = s[right];
    s[right--] = tmp;
    helper(s, left, right);
}
Run Code Online (Sandbox Code Playgroud)

科特林:

fun reverseString(s: CharArray): Unit {
    helper(0, s.lastIndex, s)
}

fun helper(i: Int, j: Int, s: CharArray) {
    if (i >= j) {
        return
    }
    val t = s[j]
    s[j] = s[i]
    s[i] = t …
Run Code Online (Sandbox Code Playgroud)

java recursion kotlin

13
推荐指数
1
解决办法
504
查看次数

Spring Boot 从 AWS 参数存储读取参数

我创建了 spring boot(gradle) 应用程序,并包含了依赖项: org.springframework.cloud:spring-cloud-starter-aws-parameter-store-config.

我想用来AWSSimpleSystemsManagement从 AWS 参数存储中读取配置,但我被迫这样写(在 aws 中):

 config/application_dev/server.port: 8080
Run Code Online (Sandbox Code Playgroud)

有什么办法可以从spring boot中读取这样的内容: dev.application.server.port:8080

目前我认为所有这些都是通过自动配置管理的,有没有办法覆盖它

java spring amazon-web-services spring-boot aws-parameter-store

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

Spring Security WebFlux 注销

类似于注销时,使会话无效并删除 WebFlux 中的 cookie 的等效方法是什么

public class SecurityConfig extends WebSecurityConfigurerAdapter {



    @Override
    protected void configure(HttpSecurity http) throws Exception
    {
        http
        .httpBasic()
        .and()
        .logout().clearAuthentication(true)
        .logoutSuccessUrl("/")
        .deleteCookies("JSESSIONID")
        .invalidateHttpSession(true)
        .and()
...
Run Code Online (Sandbox Code Playgroud)

spring-security spring-boot spring-webflux

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

Mongorestore 问题 身份验证失败

mongorestore -h ds121312.mlab.com:21312 -d heroku_jzxndzbk -u heroku_jzxndzbk -p xxxxxxxxxxxxxxx  dump/Loc8r
Run Code Online (Sandbox Code Playgroud)

错误:

2019-12-20T11:36:55.931-0500    error connecting to host: could not connect to server: connection() : auth error: sasl conversation error: unable to authenticate using mechanism "SCRA
M-SHA-1": (AuthenticationFailed) Authentication failed.
Run Code Online (Sandbox Code Playgroud)

我正在关注 Holmes/Harber 的“Getting MEAN”文本 - 第 152 页。

有什么建议?谢谢

mongodb

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

如何使用 openapi-generator 生成 API 文档?

我是OpenAPI3.0.0 的新手。

我已经使用openapi-generator成功创建了一个 java 客户端库。

但是OpenAPIGenerator 允许生成 API 客户端库(SDK 生成)、服务器存根、文档。所以我想知道是否有任何命令或步骤可用于生成 HTML 文档以及自定义文档模板。

yaml api-doc openapi openapi-generator

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

使用 HQL 进行条件更新

我正在尝试使用以下脚本更新数据库的某些行,该脚本运行得很好:

update DOS
set NAMEDOS=:name,
AGEDOS=:age,
WEIGHTDOS=:weight
where CODEDOS=:code
Run Code Online (Sandbox Code Playgroud)

我的问题如下,有时权重可能为空或为空,所以我必须设置其他属性。

我尝试像这样进行,但似乎不起作用:

update DOS
set NAMEDOS=:name,
AGEDOS=:age,
WEIGHTDOS= (case when weight is not null then :weight else :WEIGHTDOS end),
where CODEDOS=:code
Run Code Online (Sandbox Code Playgroud)

你能帮我吗。

java hibernate hql

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

无法使用snowsql连接到Snowflake数据库

我无法通过 Windows 控制台连接 Snowsql:

<!-- language: lang-html -->
    C:\Users\musik>snowsql -a [myAccount] -u [myUserName]<br>
    Installing version: 1.2.0  [####################################]  100%<br>
    Password:<br>
<!-- end snippet -->
Run Code Online (Sandbox Code Playgroud)

我收到此错误消息:

250001 (08001): Failed to connect to DB. Verify the account name is correct: [myAccount].snowflakecomputing.com:443. HTTP 403: Forbidden
If the error message is unclear, enable logging using -o log_level=DEBUG and see the log to find out the cause. Contact support for further help.
Goodbye!
Run Code Online (Sandbox Code Playgroud)

截屏

然后我用了-o log_level=DEBUG. 在日志文件中,我可以看到出现“禁止”错误:

2019-12-05 16:45:16,510 (6472/MainThread) snowflake.connector.network DEBUG        network:822  - …
Run Code Online (Sandbox Code Playgroud)

snowflake-cloud-data-platform snowsql

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

为什么字符串“:n”被Java中的replaceAll()方法认为与“.n”相同?

为什么:0在语句是 for 时被替换.0

我在 Intellij 以及在线编译器上使用:x&.x和 进行了尝试gdb,但此问题仍然存在。

public class Main
{
    public static void main(String[] args) 
    {
        String s = "Hello:0, World:0.0, het:0";    
        System.out.println(s);

        s = s.replaceAll(".0,", ",");
        System.out.println(s);
    }
}
Run Code Online (Sandbox Code Playgroud)

输出:

Hello:0, World:0.0, het:0
Hello, World:0, het:0
Run Code Online (Sandbox Code Playgroud)

java string replaceall

0
推荐指数
1
解决办法
71
查看次数