很多。 已经是到了不兼容的情况了。 JDK 每一次版本升级都带来很大麻烦。 现在主流可能还是用 JDK 8。 JDK 9 有些已知问题,如果你希望跨过 JDK 8 ,最好开始使用 JDK 11
很多。 已经是到了不兼容的情况了。 JDK 每一次版本升级都带来很大麻烦。 现在主流可能还是用 JDK 8。 JDK 9 有些已知问题,如果你希望跨过 JDK 8 ,最好开始使用 JDK 11
运行 Hibernate 测试的时候错误提示: log4j:WARN No appenders could be found for logger (org.jboss.logging). log4j:WARN Please initialize the log4j system properly. java.lang.NoSuchFieldError: TRACE at org.jboss.logging.Log4jLogger.translate(Log4jLogger.java:55) at org.jboss.logging.Log4jLogger.isEnabled(Log4jLogger.java:35) at org.jboss.logging.Logger.isTraceEnabled(Logger.java:98) at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.registerStrategyImplementor(StrategySelectorImpl.java:69) at org.hibernate.boot.registry.selector.internal.StrategySelectorBuilder.addDialect(StrategySelectorBuilder.java:251) at org.hibernate.boot.registry.selector.internal.StrategySelectorBuilder.addDialects(StrategySelectorBuilder.java:198) at org.hibernate.boot.registry.selector.internal.StrategySelectorBuilder.buildSelector(StrategySelectorBuilder.java:163) at org.hibernate.boot.registry.BootstrapServiceRegistryBuilder.build(BootstrapServiceRegistryBuilder.java:232) at org.hibernate.cfg.Configuration.<init>(Configuration.java:118) at com.ossez.covid19.common.Factory.initSession(Factory.java:96) at com.ossez.covid19.common.Factory.getFactory(Factory.java:85) at com.ossez.covid19.common.Factory.getSession(Factory.java:75) at com.ossez.covid19.common.Factory.beginTransaction(Factory.java:111) at com.ossez.covid19.tests.Covid19Test.setUp(Covid19Test.java:42) at junit.framework.TestCase.runBare(TestCase.java:132) at junit.framework.TestResult$1.protect(TestResult.java:110) at junit.framework.TestResult.runProtected(TestResult.java:128) at junit.framework.TestResult.run(TestResult.java:113) at junit.framework.TestCase.run(TestCase.java:124) at junit.framework.TestSuite.runTest(TestSuite.java:243) at junit.framework.TestSuite.run(TestSuite.java:238) at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83) at org.junit.runner.JUnitCore.run(JUnitCore.java:157) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58) Process finished with exit code -1 这个情况应该是你的依赖中没有 log4j 如果你使用的是 Gradle 的话请添加: Add org.apache.logging.log4j:log4j-core:2.13.1 到 依赖中。 请参考: OSSEZ-44 - Covid19Test 运行出现日志错误 In Progress
首先进入你需要转换的项目,然后选择 项目设置 在项目设置中,可以选择 scheme 选择 Action 下面的不同参数配置。 如果你没有管理员权限的话,在这里就不能进行操作了,否则的话需要提示你输入你的用户名和密码后继续。 选择不同的问题类型,然后单击 OK 后继续。 单击下一步继续 这里需要调整不同类型问题的映射关系。 在 Scrum 中使用的是 Story。 可以不用配置,然后下一步继续。 单击完成后进行类型配置的转换。 在转换成功后,你需要再次进入 Project ,然后在 Project 页面的左侧创建 Scurm 的面板。 https://www.cwiki.us/display/JIRA/questions/57938883
看你有多少API,API 访问量有多大,API 用途是什么。 对于一般量级别的,基本上做这种统一设计意义不大,代码丑点能实现就行。如果你就那么为数不多的API,url 规范化点就行了。 对于这种统一入口路径的,基本上我们用的是API 网关转发的方式。 因为历史遗留问题,后台有多个平台要交换数据,这个时候我们都会把请求发到一个API 网关,由网关负责转发。 对于轻量,不跨平台系统的,这种设计复杂性太高,没必要。
安装的过程比较简单。 但是这里有一个地方需要注意,如果你希望是能够通过网络访问你安装的数据库的话。 在你设置好用户名和密码,以及访问权限后,你可能发现你还是访问不了。 这是因为你的安装服务器只绑定了能够本地访问,你需要修改配置,让你的服务器能够支持远程访问。 具体的方法,请参考 RaspberryPi(树莓派)安装 MariaDB 数据库没有办法远程访问 页面中的文章。 更新系统 通过运行命令: sudo apt-get update 来对你需要安装的系统进行更新,根据网络的情况可能需要的时间也不相同。 我们更新后系统的输出内容为: root@raspberrypi:~# sudo apt-get update Hit:1 http://archive.raspberrypi.org/debian buster InRelease Get:2 http://raspbian.raspberrypi.org/raspbian buster InRelease [15.0 kB] Get:3 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages [13.0 MB] Fetched 13.0 MB in 19s (694 kB/s) Reading package lists... Done root@raspberrypi:~# 安装数据库 通过下面的情况就可以自动执行安装了: sudo apt-get install mariadb-server 设置安全 当服务器安装完成后,你需要运行: sudo mysql_secure_installation 来为你的数据库设置安全。 主要这个用途是设置你 root 的密码,root 的远程访问权限,是否允许匿名访问,是否允许远程访问等。 如果你只是测试在本地使用这个数据库,你可以不用设置这个。 但是我们还是建议你设置。 单独设置一个可以远程访问的用户 你可以单独设置一个用户能具有足够 root 的权限执行所有操作,可以进行远程访问。 你也可以使用 root 用户进行配置,但是我们不建议你使用 root 用户。 在你安装的服务器上,使用 mysql 登录到服务器上。 然后执行下面的命令: CREATE USER 'honeymoose'@'%' IDENTIFIED BY '12345678'; GRANT USAGE ON *.* TO 'honeymoose'@'%'; GRANT ALL PRIVILEGES ON *.* TO 'honeymoose'@'%' IDENTIFIED BY '12345678' WITH GRANT OPTION; FLUSH PRIVILEGES; 请注意,上面的命令是在你使用 root 登录到服务器上后进行数据库的授权的。 执行上面 SQL 的意图是,创建一个用户,为用户赋权。 修改配置允许远程访问 如果你现在进行远程连接 MariaDB / MySQL 的时候,你会收到连接 10061 的错误。 按照我们前面的提示,这是因为绑定的问题。 旧版本的MySQL修改/etc/mysql/my.cnf文件,修改内容相同。 如果你的服务上的版本没有这个文件的话,新版本的服务器,你需要修改: /etc/mysql/mariadb.conf.d/50-server.cnf 这个文件。 注释掉 ’bind-address 必要的话,可以尝试重启服务器。 重启服务器的命令是: root@raspberrypi:~# service mariadb restart 查看数据库服务器进程是是否运行的命令是: service mariadb status 如果服务器输出下面的信息,表示服务器已经运行了,你可以尝试使用 Client 远程进行连接了。 root@raspberrypi:~# service mariadb status ● mariadb.service - MariaDB 10.3.22 database server Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled) Active: active (running) since Sun 2020-04-05 10:57:14 EDT; 11s ago Docs: man:mysqld(8) https://mariadb.com/kb/en/library/systemd/ Process: 1691 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS) Process: 1692 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS) Process: 1694 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ] && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS Process: 1771 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS) Process: 1773 ExecStartPost=/etc/mysql/debian-start (code=exited, status=0/SUCCESS) Main PID: 1740 (mysqld) Status: "Taking your SQL requests now..." Tasks: 31 (limit: 4035) Memory: 47.7M CGroup: /system.slice/mariadb.service └─1740 /usr/sbin/mysqld Apr 05 10:57:13 raspberrypi systemd[1]: Starting…
在 RaspberryPi(树莓派) 上安装 MariaDB 或者 MySQL 数据库的时候。 设置的用户没有办法通过网络远程登录。 首先确定的是,用户已经设置了访问权限。 提示的错误信息是: ERROR 2002 (HY000): Can't connect to MySQL server on '192.168.0.201' (115) 其中地址 192.168.0.201 是 RaspberryPi(树莓派)的地址 这里是一个有关 RaspberryPi(树莓派)的配置问题。 你可以使用 nano /etc/mysql/mariadb.conf.d/50-server.cnf 编辑这个文件。 找到 #bind-address = 127.0.0.1 这个语句。 如果你没有注释掉这个语句的话,你需要注释掉。 因为如果你不注释掉这个,你的 MariaDB 数据库只会绑定 127.0.0.1 的地址,这样的话你只能在 localhost 上登录。 随后你可以尝试通过网络访问你的数据库了。 https://www.cwiki.us/questions/57938841
如果你希望在 Spring Boot 启用 H2 数据库的话,这篇文章适合你进行了解。 概述 在这个指南中,我们将会考虑如何在 Spring Boot 中使用 H2 数据库。 与其他数据库相似,Spring Boot 生态系统中能够完全支持 H2 数据库 依赖(Dependencies) 让我们首先需要定义 H2 数据库依赖:https://search.maven.org/search?q=g:com.h2database 同时我们还需要使用 spring-boot-starter-data-jpa 依赖:https://search.maven.org/search?q=a:spring-boot-starter-data-jpa <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> <version>2.1.4.RELEASE</version> </dependency> <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <scope>runtime</scope> <version>1.4.199</version> </dependency> 与其他的 Spring Boot 管理相似,通常你不需要为你使用的 Spring Boot 指定版本号。 数据库配置 在默认的情况下,Spring Boot 将会配置 H2 数据库使用 sa 为用户名,用户名密码为空。 当然你可以可以通过修改 application.properties 文件中配置文件来为你的 H2 数据库指定登录的用户名和密码。 spring.datasource.url=jdbc:h2:mem:testdb spring.datasource.driverClassName=org.h2.Driver spring.datasource.username=sa spring.datasource.password=password spring.jpa.database-platform=org.hibernate.dialect.H2Dialect 如果你使用的 H2 基于内存的数据库的话,你所有存储在内存中的数据将会在你重新启动服务器的时候完全丢失。 如果你希望避免这个情况的话,你可以使用基于文件存储的数据库,你可以通过下面的参数修改为基于文件使用的数据库,修改 spring.datasource.url: 参数为 spring.datasource.url=jdbc:h2:file:/data/demo 文件系统使用的路径为绝对路径,有关 H2 数据库配置的方法,请参考 http://www.h2database.com/html/features.html#connection_modes 页面中的内容。 数据库选项 Spring Boot 整合 H2 提供的增删改查(CRUD)与普通数据库的增删改查是相似的。请参考 https://www.baeldung.com/persistence-with-spring-series 页面中获得更多的有关数据持久化相关的信息。 在这里,请将 data.sql 文件添加到 src/main/resources 目录下面: DROP TABLE IF EXISTS billionaires; CREATE TABLE billionaires ( id INT AUTO_INCREMENT PRIMARY KEY, first_name VARCHAR(250) NOT NULL, last_name VARCHAR(250) NOT NULL, career VARCHAR(250) DEFAULT NULL ); INSERT INTO billionaires (first_name, last_name, career) VALUES ('Aliko', 'Dangote', 'Billionaire Industrialist'), ('Bill', 'Gates', 'Billionaire Tech Entrepreneur'), ('Folrunsho', 'Alakija', 'Billionaire Oil Magnate'); Spring Boot 将会在系统应用程序启动后,将会自动选择 data.sql 文件然后在我们的 H2 数据库中进行配置。 这种方式是对使用的数据库进行进行测试的比较好的办法。 访问 H2 控制台 H2 数据库有一个嵌入式 GUI 控制台能够让你对数据库的内容进行查询和运行 SQL。 在默认情况下,H2 的控制台没有嵌入到 Spring 中。所以你需要对这个控制台工具进行启用,请在 application.properties 文件中添加下面的参数: spring.h2.console.enabled=true 在启用上面的参数后,如果你启用了 Spring Boot 应用程序,你可以导航到 http://localhost:8080/h2-console界面中,在这个界面中首先将会显示登录界面。 在登录界面中适用的登录信息是你在 application.properties 文件中指定的登录信息。 一旦你成功连接到控制台后,我们将会看到一个完整的控制台界面。 在这个完整的控制台界面中的作出,你将会看到 H2 数据库中所有的数据表,同时还包含有一个文本对话框中包含了可以运行的 SQL 查询: 在这个 Web 的控制台界面中,具有自动完成 SQL 关键字的功能。这个功能能够让给控制台更加轻量的运行并且具有 SQL 关键字帮助的功能,能够让你在文本对话框中直接运行 SQL 脚本。 更进一步,我们将会在 application.properties 中配置更多的参数能够满足你的对当前项目的需求: spring.h2.console.path=/h2-console spring.h2.console.settings.trace=false spring.h2.console.settings.web-allow-others=false 在上面的代码中,我们设置了 H2 的控制台访问控制台的 URL 为: /h2-console,这个链接是针对你当前项目运行的服务器地址和端口的相对地址。 例如你当前服务器运行的 URL 为 http://localhost:9001 那么 H2 控制台访问的地址为 http://localhost:9001/h2-console。 同时我们设置了 spring.h2.console.settings.trace 参数为 false,这样我们能够避免在系统控制台中输出 trace 级别的日志信息。 通过设置 spring.h2.console.settings.web-allow-others=false 参数,我们能够禁止远程 Web 访问 H2 数据库的信息。 结论 H2 是完全与 Spring Boot 兼容的,通过这篇文章,你能够了解如何使用 H2 控制台来管理整治运行的数据库。 有关完整的代码情况参考我们提交到 GitHub 中的代码示例:https://github.com/cwiki-us-demo/java-tutorials/tree/master/persistence-modules/spring-boot-persistence-h2-console 中的内容。 LikeBe the first to like this
如何在 Spring Boot 中如何启用 H2 的控制台? 你需要在你的 application.properties 文件中启用配置: spring.h2.console.enabled=true spring.h2.console.path=/h2-console 具体的配置你可以参考页面 Spring Boot 使用 H2 数据库的控制台(Console) 中的内容。 运行后的界面如下: 使用的端口,是你 Spring Boot 运行使用的端口。 登录进去数据库后查看的界面: 你也可以访问 GitHub 上面的内容下载代码: https://github.com/cwiki-us-demo/java-tutorials/tree/master/persistence-modules/spring-boot-persistence-h2-console 有关本内容的链接: https://www.cwiki.us/display/SpringBootZH/questions/57938823
对需要导入使用 SQL 文件,已经放置到了 resources\data-trans.sql 下面了。 但是在配置的时候配置: spring.datasource.data=data-trans.sql 显示这个数据库 SQL 文件找不到。 错误的信息为: Property spring.datasource.data with value 'ServletContext resource [/data-trans.sql]' is invalid: The specified resource does not exist. 你需要将 spring.datasource.data=data-trans.sql 的文件路径配置参数修改为: spring.datasource.data=classpath:data-trans.sql 或 spring.datasource.data=classpath:/data-trans.sql 都可以,这个主要告诉 Spring Boot 载入数据文件的路径。 https://www.cwiki.us/display/SpringBootZH/questions/57938806
在 Spring Boot 启动的时候,在进程完成后会自动退出。 如何让 Spring Boot 以 Web 方式启动,并且进程不退出呢? 需要确定下 Web 的这个依赖是否在你的依赖中。 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> 如果没有的话,你需要讲上面的依赖添加到你的项目中。 然后再重新启动后,你会发现你的 Web 应用没有在完成后自动退出了。 https://www.cwiki.us/display/SpringBootZH/questions/57938770