我们正在尝试使用 LDAP 进行身份验证构建一个 Spring 应用程序,但是一旦我们覆盖 WebSecurityConfigurerAdapter 中的配置方法,我们就会收到 NoClassDefFoundError。
我们的应用程序是用 java11 编写的,我们使用基于代码/基于注释的配置。我们在使用 Spring 嵌入式 LDAP 服务器时遇到了一些问题,因此我们切换到 OpenLDAP。我们使用 JXplorer 验证了服务器。
这就是我们当前的方法:
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.ldap.core.support.LdapContextSource;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
@Configuration
@EnableWebSecurity
public class LdapTestConfig extends WebSecurityConfigurerAdapter
{
@Autowired
Environment env;
public LdapContextSource contextSource()
{
LdapContextSource contextSource = new LdapContextSource();
contextSource.setUrl(env.getRequiredProperty("ldap.url"));
contextSource.setBase(env.getRequiredProperty("ldap.baseDn"));
contextSource.setUserDn(env.getRequiredProperty("ldap.bindDn"));
contextSource.setPassword(env.getRequiredProperty("ldap.password"));
contextSource.afterPropertiesSet();
return contextSource;
}
// This is the method, causing my issue
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception
{ …Run Code Online (Sandbox Code Playgroud) 我一直在使用EWS(Exchange Web Service)从Java 8中的共享邮箱中读取电子邮件。
升级到Java 11 (Open JDK 11/Zulu Java 11)后,在阅读电子邮件时遇到异常。
这是例外:
java.lang.NoClassDefFoundError: javax/xml/ws/http/HTTPException在 Microsoft.exchange.webservices.data.core.ExchangeService.internalFindFolders(ExchangeService.java:370) ~[ews-java-api-2.0.jar:na]
JavaFX我正在将使用fromJava 1.7的应用程序迁移到Java 11。我遇到的错误之一是关于StageHelper.getStages()已经消失的方法。我没有找到任何东西可以替代它。您有替代此方法的解决方案吗?感谢您的帮助 !:)
我希望避免一些样板代码。我看到jdk14有记录,如下例所示。
https://www.logicbig.com/tutorials/core-java-tutorial/java-14-changes/records.html
我怎样才能做类似jdk11中的记录的事情?
我正在尝试使用单个方法(当然)在 Java 中创建一个功能接口,该方法可以采用任何类型的参数并返回任何数据类型(即泛型方法)。
这是我到目前为止:
计算器.java
public interface Calculator<T> {
T operation(T n1, T... n2); //this is where the optional parameter comes in
}
Run Code Online (Sandbox Code Playgroud)
主程序
public static void main(String[] args) {
Calculator<Integer> addition = (n1, n2) -> n1 + n2; //this gives an error
}
Run Code Online (Sandbox Code Playgroud)
错误说:
二元运算符“+”的错误操作数类型
我正在尝试在 Intelj 中构建基于 LibericaJDK 的 JavaFX 应用程序,该应用程序应该支持 JavaFX/OpenJFX)。所以我不声明任何此类依赖项。但构建失败,提示无法找到 Javafx 相关包。是否可以使用 LibericaJDK 编译开箱即用的 JavaFX 应用程序?或者这是我缺少的 intellij 设置?
我正在根据语言和地区设置区域设置,并希望使用此设置解析 BigDecimal 数字。但我面临的问题是两个 OpenJDK 的分组分隔符不同。
下面是我尝试使用 OpenJDK 8 和 OpenJDK 11 执行的示例代码。
Locale l = new Locale.Builder().setLanguage("de").setRegion("CH").build();
System.out.println("Locale set to " + Locale.getDefault(Locale.Category.FORMAT));
DecimalFormat nf = (DecimalFormat)NumberFormat.getInstance(Locale.getDefault(Locale.Category.FORMAT));
System.out.println("Grouping Separator: " + nf.getDecimalFormatSymbols().getGroupingSeparator());
Run Code Online (Sandbox Code Playgroud)
输出
OpenJDK 8
---------
Locale set to de_CH
Grouping Separator: '
OpenJDK 11
----------
Locale set to de_CH
Grouping Separator: ’
Run Code Online (Sandbox Code Playgroud)
我需要一个通用的解析方法,其中分组分隔符返回相同,以便设计我的单元测试很容易,并且无论是使用 java 8 还是 11 运行它都会通过。请协助。
我尝试运行 java awt 程序,但出现以下错误:
我正在使用 lubuntu 18.04 和 openjdk 11
Exception in thread "main" java.lang.UnsatisfiedLinkError: Can't load library: /usr/lib/jvm/java-11-openjdk-amd64/lib/libawt_xawt.so
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2630)
at java.base/java.lang.Runtime.load0(Runtime.java:768)
at java.base/java.lang.System.load(System.java:1837)
at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method)
at java.base/java.lang.ClassLoader$NativeLibrary.load(ClassLoader.java:2442)
at java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(ClassLoader.java:2498)
at java.base/java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2694)
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2648)
at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:830)
at java.base/java.lang.System.loadLibrary(System.java:1873)
at java.desktop/java.awt.Toolkit$3.run(Toolkit.java:1399)
at java.desktop/java.awt.Toolkit$3.run(Toolkit.java:1397)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.desktop/java.awt.Toolkit.loadLibraries(Toolkit.java:1396)
at java.desktop/java.awt.Toolkit.<clinit>(Toolkit.java:1429)
at java.desktop/java.awt.Component.<clinit>(Component.java:621)
Run Code Online (Sandbox Code Playgroud)
这是我在编辑器中编写的代码:
class calculator extends Frame{
calculator(){
Button b=new Button("click me");
b.setBounds(30,100,80,30);
add(b);
setSize(300,300);
setLayout(null);
setVisible(true);
}
public static void main(String args[]){
calculator f=new calculator();
}}
Run Code Online (Sandbox Code Playgroud)
我可以在 openjdk …
我正在将我的一个项目从 JDK8 迁移到 JDK11,但是其中一个单元测试失败了,尽管我想出了如何在 JDK11 中解决此问题的解决方案,但我不知道其背后的原因。如果有人向我解释这一变化,我真的很感激。这是适用于 JDK8 但不适用于 JDK11 的 HashSet:
Set<String> func(Properties p, String s) {
Set<String> set = p.stringPropertyNames();
set.removeIf(s -> !s.startsWith(s));
return set;
}
Run Code Online (Sandbox Code Playgroud)
我不得不像这样更改 HashSet 初始化以使我的测试运行并通过 JDK11:
Set<String> set = new HashSet<>(p.stringPropertyNames());
Run Code Online (Sandbox Code Playgroud)
我不明白为什么我必须在 JDK11 中像这样更改初始化,此更改是否打算在 JDK11 中使用?
错误堆栈跟踪:
null
java.lang.UnsupportedOperationException
at java.base/java.util.Collections$UnmodifiableCollection.removeIf(Collections.java:1089)
Run Code Online (Sandbox Code Playgroud) 我正在将 java 应用程序从 java-8 迁移到 java-11,遇到问题包 sun.net.www.protocol.https 不可见。我的代码就像 URL url = new URL(null, strServletUrl, new sun.net.www.protocol.https.Handler());
那么如何在 java-11 中获取 https 处理程序,因为它在基础包中的类中不可见。