我正在使用 Eclipse 2019-03 和 Apache Tomcat 版本 8.5.45。
我已经在eclipse中添加了服务器。
运行服务器后,它给了我如下错误:
我检查了server.xml:
发现server.xml的端口号被设置为8089,所以,当我单独运行tomcat时,连接到localhost:8089. 问题仍然存在。为此,我还检查了端口8089是否正在使用中,但事实并非如此。
那么,有什么问题呢?
我有一个具有基础数据库 (Oracle) 的应用程序。它从基本数据库中的表中获取另一个租户数据库连接字符串。这些租户可以是 Oracle、Postgres 或 MSSQL。
当应用程序启动时,方言被设置为org.hibernate.dialect.SQLServerDialect基本数据库的休眠状态。但是当我尝试在 MSSQL 数据库的租户中插入数据时,它在插入数据时抛出错误。com.microsoft.sqlserver.jdbc.SQLServerException: DEFAULT 或 NULL 不允许作为显式标识值
这是因为它正在为 Oracle 数据库设置 MSSQL 方言。
[WARN ] 2020-01-21 09:16:22.504 [https-jsse-nio-22500-exec-5] [o.h.e.j.s.SqlExceptionHelper] -- SQL Error: 339, SQLState: S0001
[ERROR] 2020-01-21 09:16:22.504 [https-jsse-nio-22500-exec-5] [o.h.e.j.s.SqlExceptionHelper] -- DEFAULT or NULL are not allowed as explicit identity values.
[ERROR] 2020-01-21 09:16:22.535 [https-jsse-nio-22500-exec-5] [o.a.c.c.C.[.[.[.[dispatcherServlet]] -- Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute statement; SQL [n/a]; nested …Run Code Online (Sandbox Code Playgroud) 我正在尝试将我的代码从 Java 8 移动到 Java 11,这段代码......
private static String readMultiHttpsUrlResultAsString(List<String> mbRecordingIds, String level) throws Exception
{
String result = "";
class NaiveTrustStrategy implements TrustStrategy
{
@Override
public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException
{
return true;
}
};
SSLContext sslcontext = org.apache.http.ssl.SSLContexts.custom()
.loadTrustMaterial(new NaiveTrustStrategy())
.build();
CloseableHttpClient httpclient = HttpClients.custom()
.setSSLSocketFactory(new SSLConnectionSocketFactory(sslcontext))
.build();
StringBuilder sb = new StringBuilder("?recording_ids=");
for(String next:mbRecordingIds)
{
sb.append(next + ";");
}
sb.setLength(sb.length() - 1);
try
{
String url = "https://acousticbrainz.org/api/v1"+level+sb;
HttpGet httpget = new HttpGet(url);
try …Run Code Online (Sandbox Code Playgroud) 第一个依赖项是验证 xml 文件。
<dependency>
<groupId>xerces</groupId>
<artifactId>xerces</artifactId>
<version>2.4.0</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
第二个依赖项是将 POI 对象写入文件。
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.12.0</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
现在,我需要一个如下所示的解决方案:
<dependency>
<groupId>xerces</groupId>
<artifactId>xerces</artifactId>
<artifactId>xercesImpl</artifactId>
<version>2.12.0</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
有可能实现这一目标吗?
调用函数时
testFunc(),我没有使用语法Apples.testFunc()。但是代码运行成功。为何如此?
class Apples {
public static void main(String args[] ) {
testFunc();
}
public static void testFunc() {
System.out.println("Hello world!");
}
}
Run Code Online (Sandbox Code Playgroud) 服务器启动时我收到此警告。
INFO 13868 --- s.DynamoDBRepositoryFactory : Spring Data Version: 2.3.7.RELEASE
INFO 13868 --- s.DynamoDBRepositoryFactory : AWS SDK Version: 1.11.64
INFO 13868 --- s.DynamoDBRepositoryFactory : Java Version: 11.0.7 - Java HotSpot(TM) 64-Bit Server VM 11.0.7+8-LTS
INFO 13868 --- s.DynamoDBRepositoryFactory : Platform Details: Windows 10 10.0
WARN 13868 --- s.DynamoDBRepositoryFactory : This Spring Data DynamoDB implementation might not be compatible with the available Spring Data classes on the classpath!
Run Code Online (Sandbox Code Playgroud)
https://github.com/boostchicken/spring-data-dynamodb
这就是 gradle 依赖。
plugins {
id("org.springframework.boot") version "2.4.3"
id("io.spring.dependency-management") version "1.0.11.RELEASE"
id("com.google.cloud.tools.jib") …Run Code Online (Sandbox Code Playgroud) 我有一个基于 1.5.3.RELEASE 的 Spring Boot 应用程序,它在 2.6.1 中利用 springfox-swagger2 ,在 2.6.1 中利用 springfox-swagger-ui 。
对于大多数 API 来说,一切都很好。GET 有效。帖子有效。PUT 总是在 swagger-ui.html 处出错,Invalid CORS request我可以使用如下请求重现问题 localhost:
$ curl -i -X PUT 'http://localhost.mycompany.com:8080/mom/749f4f1f-0769-488d-9776-17fc3927cfc6/description?description=WangoTango' \
> -H 'Origin: http://example.com' \
> -H 'Cookie: a.token_key=redacted' \
> -H 'accept: application/json'
HTTP/1.1 403
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: SAMEORIGIN
Content-Length: 20
Date: Sat, 11 Nov 2023 01:42:01 GMT
Invalid CORS request
Run Code Online (Sandbox Code Playgroud)
我的应用程序是根据https://docs.spring.io/spring-security/reference/reactive/integrations/cors.html使用 …
在我的Spring boot应用程序中,目前我有这个类:
@SpringBootApplication
public class TestApplication {
public static void main(String[] args) {
SpringApplication.run(TestApplication.class, args);
}
@Bean
public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurerAdapter() {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/user").allowedOrigins("http://localhost:3000");
}
};
}
}
Run Code Online (Sandbox Code Playgroud)
它只允许我访问或写入http://localhost:3000,但我希望这个休息方法可以被所有东西访问,比如http://localhost:1000〜http://localhost:9999或任何网站。
我怎样才能启用它?
下面的类中有一个方法:
@Override
@Transactional
@Cacheable(value = "products", key = "#id")
public Product getProduct(long id) throws ApplicationException {
Product product = null;
try {
ProductEntity productEntity = productDAO.getProduct(id);
product = productTransformer.toProduct(productEntity);
} catch (SystemException ex) {
throw new ApplicationException(ex.getCode(), ex.getMessage(), "Problem in DataLayer", "Data Layer Error",
new Object[] { ex });
}
return product;
}
Run Code Online (Sandbox Code Playgroud)
该应用程序运行良好。但我希望在数据放入缓存时有一个缓存命中日志。我想通过 log4j.properties 记录它。
如何配置 application.properties 以便可以记录它?
我想使用正则表达式替换电子邮件地址的一部分。怎么做 ?
例如:test.email+alex@gmail.com有一个电子邮件地址,我想用 '' 替换该电子邮件地址中从+到 之前的部分@,以便最终的字符串为test.email@gmail.com。
我尝试了下面给出的这个:
str.replaceAll("[^+[a-z]]","");
Run Code Online (Sandbox Code Playgroud) java ×9
spring ×5
spring-boot ×4
adoptopenjdk ×1
cors ×1
ehcache ×1
hibernate ×1
java-11 ×1
jcache ×1
maven ×1
multi-tenant ×1
regex ×1
spring-data ×1
ssl ×1
static ×1
swagger-ui ×1
tomcat ×1