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批注使用两个属性文件?
使用 Lombok 通过 Eclipse/Maven 生成代码。希望能够以文本形式查看正在生成的类。在目标下搜寻,但没有看到任何东西。有没有办法让 Lombok 输出生成的类?
春天新..
\n\n尝试使用 @Query 注释,但收到以下消息:\n此位置不允许使用注释 @Query
\n\n我所拥有的一定是我缺少的一些设置或配置:
\n\npom.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>\nRun 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\npublic interface DeptRepo extends JpaRepository<Dept, Long> {\n\n@Query(value = "select d from dept d where name = \'ACCOUNTING\'")\nList<Dept> findByAccounting;\n}\nRun Code Online (Sandbox Code Playgroud)\n\n应用程序属性
\n\nspring.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\nRun Code Online (Sandbox Code Playgroud)\n\n我的问题是我缺少什么设置信息?
\n看到了很多问题,尝试了建议,到目前为止还没有运气。当前\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 };\nRun Code Online (Sandbox Code Playgroud)\n它是 Chart.js v 3.9.1 的一部分,标签可以是未定义的
\n在 vsc 中,弹出窗口显示
\n(property) ChartData<"bar", number[], unknown>.labels?: unknown[] | undefined\nRun Code Online (Sandbox Code Playgroud)\n事件处理程序是发生错误的地方:
\n public chartClicked(e: any): …Run Code Online (Sandbox Code Playgroud) spring-boot ×2
angular ×1
chart.js ×1
hibernate ×1
javascript ×1
junit4 ×1
lombok ×1
spring ×1
typescript ×1