shaan160
shaan160
JCHJava Community | Help. Code. Learn.
Created by shaan160 on 10/24/2024 in #java-help
Issue with Java Servlet not finding classes
Hi all, i am trying to utilize my existing context config location as well as my app config. The isssue is i am trying to do dependency injection with spring, but want to do it via Java not xml. Can someone help? I am using Java Servlets, With Tomcat and Apache my xml
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/security.xml, com.utility.config.AppConfig
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/security.xml, com.utility.config.AppConfig
</param-value>
</context-param>
app config
package com.utility.config;

import com.utility.datamaintenance.products.services.ProductRetrieveService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AppConfig {
public AppConfig() {
}

@Bean
public ProductRetrieveService productRetrieveService() {
return new ProductRetrieveService();
}
}
package com.utility.config;

import com.utility.datamaintenance.products.services.ProductRetrieveService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AppConfig {
public AppConfig() {
}

@Bean
public ProductRetrieveService productRetrieveService() {
return new ProductRetrieveService();
}
}
4 replies
JCHJava Community | Help. Code. Learn.
Created by shaan160 on 11/30/2023 in #java-help
Issue with gradle multi modules
Hi everyone just a quick one, i am doing a multi-module Gradle project. When i try to load one of my other modules i get Could not determine the dependencies of task ':bootJar'.
Could not resolve all task dependencies for configuration ':runtimeClasspath'. Could not resolve project :common.
Required by: project :
No matching configuration of project :common was found. The consumer was configured to find a library for use during runtime, compatible with Java 17, packaged as a jar, preferably optimized for standard JVMs, and its dependencies declared externally but:
- None of the consumable configurations have attributes. my main build.gradle
plugins {
id 'java'
id 'org.springframework.boot' version '3.1.5'
id 'io.spring.dependency-management' version '1.1.3'
id 'org.hibernate.orm' version '6.2.13.Final'
id 'org.graalvm.buildtools.native' version '0.9.27'
id 'org.asciidoctor.jvm.convert' version '3.3.2'
}

group = 'com.university'
version = '0.0.1-SNAPSHOT'

java {
sourceCompatibility = '17'
}

repositories {
mavenCentral()
}

ext {
set('snippetsDir', file("build/generated-snippets"))
set('springCloudVersion', "2022.0.4")
}

dependencies {
...
implementation project(':common')
}

dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}

tasks.named('bootBuildImage') {
builder = 'paketobuildpacks/builder-jammy-tiny:latest'
}

tasks.named('test') {
outputs.dir snippetsDir
useJUnitPlatform()
}

tasks.named('asciidoctor') {
inputs.dir snippetsDir
dependsOn test
}

hibernate {
enhancement {
enableAssociationManagement = true
}
}
plugins {
id 'java'
id 'org.springframework.boot' version '3.1.5'
id 'io.spring.dependency-management' version '1.1.3'
id 'org.hibernate.orm' version '6.2.13.Final'
id 'org.graalvm.buildtools.native' version '0.9.27'
id 'org.asciidoctor.jvm.convert' version '3.3.2'
}

group = 'com.university'
version = '0.0.1-SNAPSHOT'

java {
sourceCompatibility = '17'
}

repositories {
mavenCentral()
}

ext {
set('snippetsDir', file("build/generated-snippets"))
set('springCloudVersion', "2022.0.4")
}

dependencies {
...
implementation project(':common')
}

dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}

tasks.named('bootBuildImage') {
builder = 'paketobuildpacks/builder-jammy-tiny:latest'
}

tasks.named('test') {
outputs.dir snippetsDir
useJUnitPlatform()
}

tasks.named('asciidoctor') {
inputs.dir snippetsDir
dependsOn test
}

hibernate {
enhancement {
enableAssociationManagement = true
}
}
my settings.gradle
rootProject.name = 'mediasystem'
include 'common', 'media_engine_service', 'authentication_service'
rootProject.name = 'mediasystem'
include 'common', 'media_engine_service', 'authentication_service'
common's gradle
plugins {
id 'java'
}

group = 'com.university'
version = '0.0.1-SNAPSHOT'

java {
sourceCompatibility = '17'
}

repositories {
mavenCentral()
}
plugins {
id 'java'
}

group = 'com.university'
version = '0.0.1-SNAPSHOT'

java {
sourceCompatibility = '17'
}

repositories {
mavenCentral()
}
4 replies