用int 效率高,便于转换,便于国际化。 不管怎么样使用中文也好英文也罢,字符占用存储比 int 要多,中文更多了。int 数据库好索引,查询快。 国际化 字符 map 方便。 另外这个是大家都懂的定义,提高代码可读性。要知道你的代码有时候也是要给别人读的。有时候可能看起来不太好的,但是也都是习惯了,更多的惯例就是规定。 https://www.ossez.com/t/int/769
用int 效率高,便于转换,便于国际化。 不管怎么样使用中文也好英文也罢,字符占用存储比 int 要多,中文更多了。int 数据库好索引,查询快。 国际化 字符 map 方便。 另外这个是大家都懂的定义,提高代码可读性。要知道你的代码有时候也是要给别人读的。有时候可能看起来不太好的,但是也都是习惯了,更多的惯例就是规定。 https://www.ossez.com/t/int/769
Spring Boot 在运行 API 的时候如果返回数据库的时候提示中文是乱码。 但是针对不同的浏览器,返回的结果是不一样的。 在 Application.yml 中 添加下面的配置: server: servlet: encoding: force: true charset: UTF-8 enabled: true 然后重新启动服务器后,我们所有的访问都会使用 UTF-8 编码。 这样以避免字符集错误。 需要注意的是,不同的浏览器对字符集的编码是不一样的,最好都测一下。 针对手机平台也是不一样的。 https://www.ossez.com/t/spring-boot-api/768
获得的错误信息为: Exception in thread "main" java.lang.IllegalStateException: Logback configuration error detected: ERROR in ch.qos.logback.core.joran.util.PropertySetter@34237b90 - A "net.logstash.logback.encoder.LogstashEncoder" object is not assignable to a "ch.qos.logback.core.Appender" variable. ERROR in ch.qos.logback.core.joran.util.PropertySetter@34237b90 - The class "ch.qos.logback.core.Appender" was loaded by ERROR in ch.qos.logback.core.joran.util.PropertySetter@34237b90 - [jdk.internal.loader.ClassLoaders$AppClassLoader@16f65612] whereas object of type ERROR in ch.qos.logback.core.joran.util.PropertySetter@34237b90 - "net.logstash.logback.encoder.LogstashEncoder" was loaded by [jdk.internal.loader.ClassLoaders$AppClassLoader@16f65612]. at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:169) at org.springframework.boot.logging.logback.LogbackLoggingSystem.reinitialize(LogbackLoggingSystem.java:222) at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:73) at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:60) at org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:118) at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:306) at org.springframework.boot.context.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:281) at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:239) at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:216) at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127) at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:80) at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:53) at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:345) at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) at com.ossez.edtestbank.service.Application.main(Application.java:44) 问题和解决 这个是包的兼容性问题。 logback-core 需要设置为 1.2.0 版本,如果你设置了更高的版本的话,你就会遇到上面的问题。 请参考下面链接中的问题: https://jira.qos.ch/browse/LOGBACK-1326 貌似到现在还没有解决。 如果你还希望使用 logstash-logback-encoder 的话,那么需要将 logback 设置为 1.2.0 版本。 https://www.ossez.com/t/logstash-logback-encoder-logback/767
提示的错误信息如下: *Command line is too long*. Shorten *command line* for 解决办法 有下面 2 个方法都可以解决这个问题。 修改应用 首先需要选择 Application,然后选择编辑。 然后通过上面选择 JAR 的配置。 修改 workspace.xml 然后修改 workspace.xml 文件,针对 PropertiesComponent 组件,添加下面的参数: <property name="dynamic.classpath" value="true" /> 然后重新启动后就可以解决这个问题了。 https://www.ossez.com/t/spring-boot-intellij-command-line-is-too-long-shorten-command-line-for/763
你可能有下面的一些安装目录: /usr/lib/jenkins/:jenkins安装目录,WAR包会放在这里。 /etc/sysconfig/jenkins:jenkins配置文件,“端口”,“JENKINS_HOME”等都可以在这里配置。 /var/lib/jenkins/:默认的JENKINS_HOME。 /var/log/jenkins/jenkins.log:Jenkins日志文件。 https://www.ossez.com/t/jenkins-linux/762
Jenkins 的文件结构目录如下。 在 CentOS 8 的操作系统下,具体的路径是在 /var/lib 目录下的。 所有的配置文件都在这里,包括有你 Job,这是你的任务目录。 JENKINS_HOME +- config.xml (jenkins root configuration) +- *.xml (other site-wide configuration files) +- userContent (files in this directory will be served under your http://server/userContent/) +- fingerprints (stores fingerprint records) +- nodes (slave configurations) +- plugins (stores plugins) +- secrets (secretes needed when migrating credentials to other servers) +- workspace (working directory for the version control system) +- [JOBNAME] (sub directory for each job) +- jobs +- [JOBNAME] (sub directory for each job) +- config.xml (job configuration file) +- latest (symbolic link to the last successful build) +- builds +- [BUILD_ID] (for each build) +- build.xml (build result summary) +- log (log file) +- changelog.xml (change log) 具体的官方文档参考地址为:https://wiki.jenkins.io/display/JENKINS/Administering+Jenkins https://www.ossez.com/t/jenkins-centos-8/757
在使用 Jenkins 进行编译的时候提示错误: The JAVA_HOME environment variable is not defined correctly This environment variable is needed to run this program NB: JAVA_HOME should point to a JDK not a JRE 解决办法 在 Jenkins 中选择 Manage Jenkins,然后选择 配置系统. 配置系统 然后选择全局属性后,添加一个变量为 JAVA_HOME 就可以解决这个问题了。 然后再重新编译后就可以解决参数配置问题。 https://www.ossez.com/t/jenkins-java-home-environment/761
Jenkins 使用的默认端口是 8080。 在 CentOS 你可以通过修改 /etc/sysconfig/jenkins 文件中的 JENKINS_PORT=“8080” 端口来修改 Jenkins 使用默认的端口。 当你重新启动后,就可以使用新的端口了。 https://www.ossez.com/t/jenkins-centos-8/758
一般来说你可以使用 Apache Tika 来获得文件的类型。 Tika 是一个内容分析工具 Maven 设置 maven 的版本到你的 POM 文件中。 <!-- https://mvnrepository.com/artifact/org.apache.tika/tika-core --> <dependency> <groupId>org.apache.tika</groupId> <artifactId>tika-core</artifactId> <version>1.25</version> </dependency> 测试代码 例如,我们可以使用下面的测试代码。 @Test public void whenUsingTika_thenSuccess() { File file = new File("product.png"); Tika tika = new Tika(); String mimeType = tika.detect(file); assertEquals(mimeType, "image/png"); } 你需要首先 New 一个文件对象,然后通过文件对象进行测试就可以了。 例如我们使用上面类似的代码测试了一些代码: 09:32:36.377 [main] DEBUG c.i.s.c.test.utilities.FileUtilsTest - TXT - [text/plain] 09:32:36.389 [main] DEBUG c.i.s.c.test.utilities.FileUtilsTest - CSV - [text/csv] 09:32:36.395 [main] DEBUG c.i.s.c.test.utilities.FileUtilsTest - XLS - [application/vnd.ms-excel] 09:32:36.399 [main] DEBUG c.i.s.c.test.utilities.FileUtilsTest - XLSX - [application/vnd.openxmlformats-officedocument.spreadsheetml.sheet] 上面测试过一些文件类和类型的返回。 https://www.ossez.com/t/java-media-type/753
在处理文件的时候 POI 提示错误: org.apache.poi.ooxml.POIXMLException: Strict OOXML isn't currently supported, please see bug #57699 at org.apache.poi.ooxml.POIXMLDocumentPart.getPartFromOPCPackage(POIXMLDocumentPart.java:779) at org.apache.poi.ooxml.POIXMLDocumentPart.<init>(POIXMLDocumentPart.java:175) at org.apache.poi.ooxml.POIXMLDocumentPart.<init>(POIXMLDocumentPart.java:165) at org.apache.poi.ooxml.POIXMLDocument.<init>(POIXMLDocument.java:61) at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:282) 这是因为你的 Excel 保存的格式版本为 Strict Open XML 格式。 你需要将这个文件保存为 Excel WorkBook 格式才能够被 POI 读取。 针对这个问题暂时没有太多的解决办法,你只能让用户保存为 Excel WorkBook 格式才能让 Apache POI 处理。 https://www.ossez.com/t/apache-poi-strict-ooxml-isnt-currently/752