小编Oxn*_*ard的帖子

Spring Boot JUnit和@TestPropertySource使用多个属性文件

Spring Boot 2.0.3。发布

有多个属性文件要处理.. application.properties和application-DEV.properties

在Junit测试中使用注解@TestPropertySource,我只能让它读取一个文件:

@TestPropertySource("file:C:\\Users\\user\\eclipse-workspace\\one2one_httpCall\\src\\main\\resources\\application-DEV.properties")
Run Code Online (Sandbox Code Playgroud)

按预期工作

但是我需要两个属性文件,但我确实看到了locations选项,但是没有看到多个文件的示例..尝试了不同的选项,但没有一个起作用:

@TestPropertySource(locations = "classpath:application-DEV.properties;classpath:application.properties")
Run Code Online (Sandbox Code Playgroud)

尝试了几种我不发布的方法,甚至尝试使用@TestPropertySource两次,但错误提示您无法两次使用。

尝试使用@PropertySource,因为您可以使用它两次,但是由于这是Junit测试,因此无法使用。看着一堆关于stacktrace和其他问题,并尝试过但没有运气。

所以我的问题是如何通过@TestPropertySource批注使用两个属性文件?

spring junit4 spring-boot

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

如何查看 lombok 生成的类

使用 Lombok 通过 Eclipse/Maven 生成代码。希望能够以文本形式查看正在生成的类。在目标下搜寻,但没有看到任何东西。有没有办法让 Lombok 输出生成的类?

lombok

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

该位置不允许查询注释

春天新..

\n\n

尝试使用 @Query 注释,但收到以下消息:\n此位置不允许使用注释 @Query

\n\n

我所拥有的一定是我缺少的一些设置或配置:

\n\n

pom.xml

\n\n
<parent>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-starter-parent</artifactId>\n <version>1.5.2.RELEASE</version>\n <relativePath/>\n</parent>\n\xe2\x80\xa6 to dependency:\n<dependency>\n  <groupId>org.springframework.boot</groupId>\n  <artifactId>spring-boot-starter-data-jpa</artifactId>      \n</dependency>\n
Run Code Online (Sandbox Code Playgroud)\n\n

被迫使用 1.5.2.RELEASE,因为它是雇主当前的标准\n查看 Maven 依赖项,我看到:\nhibernate-core-5.0.12.Final\nhibernate-jpa-2.1-api-1.0.0。 Final.jar\nspring-data-jpa-1.11.1.RELEASE.jar\n+ 许多其他

\n\n

在我看到的一些示例中,添加 @Query 注释似乎很容易,但它似乎不起作用。目前我只有一个实体、存储库、控制器和一个 main。

\n\n

我已经尝试过 @Repository 但它似乎没有什么区别

\n\n

这是回购协议

\n\n
public interface DeptRepo extends JpaRepository<Dept, Long> {\n\n@Query(value = "select d from dept d where name = \'ACCOUNTING\'")\nList<Dept> findByAccounting;\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n

应用程序属性

\n\n
spring.jpa.show_sql=true\nspring.jpa.properties.hibernate.dialect=org.hibernate.dialect.Oracle12cDialect\nspring.datasource.url=jdbc:oracle:thin:@localhost:1521/to2b\nspring.datasource.username=scott\nspring.datasource.password=tiger\n
Run Code Online (Sandbox Code Playgroud)\n\n

我的问题是我缺少什么设置信息?

\n

hibernate spring-data-jpa spring-boot

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

':'预期.ts(1005) 如何修复

看到了很多问题,尝试了建议,到目前为止还没有运气。当前\n使用来自 ng version 命令的 vsc 版本 1.76.2、Node 16.14.2 ts 版本 4.6.4

\n

条形图数据是

\n
  public barChartData: ChartData<'bar'> = {\n    labels: [],\n    datasets: [\n      {\n        data: [],\n        // data: [65, 59, 80, 81, 56, 55, 40],\n        // backgroundColor: ['#012169', '#0073cf', '#646464', '#012169', '#0073cf', '#646464', '#012169'],\n        // hoverBackgroundColor: ['#8090b4', '#80b9e7', '#919191', '#8090b4', '#80b9e7', '#919191', '#8090b4'],\n      },\n    ]\n  };\n
Run Code Online (Sandbox Code Playgroud)\n

它是 Chart.js v 3.9.1 的一部分,标签可以是未定义的

\n

在 vsc 中,弹出窗口显示

\n
(property) ChartData<"bar", number[], unknown>.labels?: unknown[] | undefined\n
Run Code Online (Sandbox Code Playgroud)\n

事件处理程序是发生错误的地方:

\n
  public chartClicked(e: any): …
Run Code Online (Sandbox Code Playgroud)

javascript typescript chart.js angular

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