Page 1 of 1

Eine Namensausnahme erfolgt beim Ausführen eines Frühlingsprojekts als ausführbare Datei (EXE)

Posted: 12 Feb 2025, 13:00
by Anonymous
Ich entwickle eine Desktop -Anwendung, die Spring und OpenJFX kombiniert, aber ich habe ein Problem, bei dem die von JPackage erstellte ausführbare Datei nicht korrekt funktioniert. Beim Überprüfen der Protokolle stellte ich fest, dass ein Javax/Naming/NamingException-Fehler auftritt.

Code: Select all

Caused by: java.lang.IllegalStateException: Could not evaluate condition on org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$PooledDataSourceConfiguration due to javax/naming/NamingException not found. Make sure your own configuration does not rely on that class. This can also happen if you are @ComponentScanning a springframework package (e.g. if you put a @ComponentScan in the default package by mistake)
< /code>
Die gleiche Ausnahme trat auch dann auf, wenn ich ein minimales Projekt erstellt habe, um die Ursache zu isolieren. Wenn Sie Informationen oder Lösungen zu ähnlichen Problemen mit NamensException haben, würde ich mich darüber freuen, wenn Sie es mich wissen lassen. In Zukunft denke ich darüber nach, Tomcat vorzustellen und mit OpenJFX WebView zu kombinieren.spring:
datasource:
url: 'jdbc:sqlite:file::memory:?cache=shared'
driver-class-name: org.sqlite.JDBC
jpa:
show-sql: true
properties:
hibernate:
dialect: 'org.hibernate.community.dialect.SQLiteDialect'

logging:
level:
org.hibernate.SQL: DEBUG
org.hibernate.type.descriptor.sql.BasicBinder: TRACE
org.springframework.boot.autoconfigure: DEBUG
< /code>
MyApp.class
@SpringBootApplication
public class MyApp extends Application {

private ConfigurableApplicationContext appContext;
private Parent root;

@Override
public void init() throws Exception{
appContext = new SpringApplicationBuilder(MyApp.class)
.run(getParameters().getRaw().toArray(new String[0]));

FXMLLoader loader = new FXMLLoader(MyApp.class.getResource("hello-view.fxml"));
root = loader.load();
}

@Override
public void start(Stage stage) {
stage.setTitle("MyAppView");

Scene scene = new Scene(root, 480, 320);
stage.setScene(scene);
stage.show();
}

@Override
public void stop(){
appContext.close();
Platform.exit();
}

public static void main(String...  args){
Application.launch(MyApp.class, args);
}

}
< /code>
MyAppDatabaseConfig.class
@Configuration(proxyBeanMethods = false)
public class MyAppDataBaseConfig {

final DataSourceProperties DATA_SOURCE_PROPERTY;

@Autowired
public MyAppDataBaseConfig(DataSourceProperties dataSource){
this.DATA_SOURCE_PROPERTY = dataSource;
}

@Bean
@Primary
public DataSource backDataSource() {
SQLiteDataSource sqlDs = new SQLiteDataSource();
sqlDs.setUrl(DATA_SOURCE_PROPERTY.getUrl());
return sqlDs;
}
}
< /code>
pom.xml
 & l t ; p r o j e c t   x m l n s = & q u o t ; h t t p : / / m a v e n . a p a c h e . o r g / P O M / 4 . 0 . 0 & q u o t ; < b r   / >                   x m l n s : x s i = & q u o t ; h t t p : / / w w w . w 3 . o r g / 2 0 0 1 / X M L S c h e m a - i n s t a n c e & q u o t ; < b r   / >                   x s i : s c h e m a L o c a t i o n = & q u o t ; h t t p : / / m a v e n . a p a c h e . o r g / P O M / 4 . 0 . 0   h t t p s : / / m a v e n . a p a c h e . o r g / x s d / m a v e n - 4 . 0 . 0 . x s d & q u o t ; & g t ; < b r   / >         & l t ; m o d e l V e r s i o n & g t ; 4 . 0 . 0 & l t ; / m o d e l V e r s i o n & g t ; < b r   / > < b r   / >         & l t ; g r o u p I d & g t ; t e s t & l t ; / g r o u p I d & g t ; < b r   / >         & l t ; a r t i f a c t I d & g t ; m y a p p & l t ; / a r t i f a c t I d & g t ; < b r   / >         & l t ; v e r s i o n & g t ; 1 . 0 - S N APSHOT
myapp


UTF-8
21
21.0.1
2.0.16



org.springframework.boot
spring-boot-starter-parent
3.4.2




org.springframework.boot
spring-boot-starter



org.projectlombok
lombok
true



org.springframework.boot
spring-boot-starter-data-jpa



org.hibernate.orm
hibernate-community-dialects
6.6.1.Final



org.xerial
sqlite-jdbc
3.46.1.0



org.openjfx
javafx-controls
${jfx.version}


org.openjfx
javafx-fxml
${jfx.version}



org.slf4j
slf4j-api
${slf4j.version}



org.slf4j
slf4j-reload4j
${slf4j.version}
test







org.apache.maven.plugins
maven-compiler-plugin
3.11.0

UTF-8
21
21




org.apache.maven.plugins
maven-dependency-plugin


copy-dependencies
package

copy-dependencies


org.openjfx
${project.build.directory}/lib
false
false
true