在使用Java 17的GeoServer 2.22.2版本中,GeoTools出现了NumericConverter错误。这是由于Java 17中的默认实现方法与GeoTools的NumericConverterFactory不兼容造成的。
要解决这个问题,需要在启动GeoServer之前将GeoTools的默认实现方法修改为Java 17中兼容的实现方法。可以使用以下代码:
import org.geotools.factory.CommonFactoryFinder;
import org.geotools.factory.FactoryRegistryException;
import org.geotools.factory.Hints;
import org.geotools.referencing.factory.epsg.ThreadedEpsgFactory;
import org.geotools.referencing.factory.epsg.direct.DirectEpsgFactory;
import org.opengis.referencing.FactoryException;
public class Main {
public static void main(String[] args) throws FactoryException, FactoryRegistryException {
Hints hints = CommonFactoryFinder.getDefaultHints();
ThreadedEpsgFactory epsgFactory = new ThreadedEpsgFactory(new DirectEpsgFactory(), "epsg");
hints.put(Hints.CRS_FACTORY, epsgFactory);
CommonFactoryFinder.reset();
System.out.println("Hints: "+hints);
}
}
运行后,将输出修改后的hints。
现在,将修改后的hints传递给GeoServer,并启动GeoServer。在启动后,检查是否已成功解决NumericConverter错误。
这是一个简单的解决方案,可能还有其他解决方法,但可以尝试使用这个方法来解决这个问题。