8wDlpd.png
8wDFp9.png
8wDEOx.png
8wDMfH.png
8wDKte.png

尝试在 ubuntu 上部署 spring boot 应用程序时出现 'UnsatisfiedDependencyException:在 URL 中定义名为 'eventService' 的 bean 时出错'

user1111 2月前

138 0

当我在 IntelliJ IDEA 的开发机器上运行该项目时,一切都运行正常,没有任何错误,但是当我尝试将其打包并部署到运行 Ubuntu 24.04 的服务器上时,我得到了

当我在 IntelliJ IDEA 中的开发机器上运行该项目时,一切都运行正常,没有任何错误,但是当我尝试将其打包并部署到运行 Ubuntu 24.04 的服务器上时,我收到这个奇怪的错误:

Jun 01 20:16:31 raspberrypi5 AnimalShelter[36353]:   .   ____          _            __ _ _
Jun 01 20:16:31 raspberrypi5 AnimalShelter[36353]:  /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
Jun 01 20:16:31 raspberrypi5 AnimalShelter[36353]: ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
Jun 01 20:16:31 raspberrypi5 AnimalShelter[36353]:  \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
Jun 01 20:16:31 raspberrypi5 AnimalShelter[36353]:   '  |____| .__|_| |_|_| |_\__, | / / / /
Jun 01 20:16:31 raspberrypi5 AnimalShelter[36353]:  =========|_|==============|___/=/_/_/_/
Jun 01 20:16:31 raspberrypi5 AnimalShelter[36353]:  :: Spring Boot ::                (v3.2.5)
Jun 01 20:16:31 raspberrypi5 AnimalShelter[36353]: 20:16:31.924 [main] INFO me.fazelukario.animalshelter.AnimalShelterApplication -- Starting AnimalShelterApplication using Java 22-ea with PID 36353 (/root/AnimalShelter/animalshelter.jar started by root in /root/AnimalShelter)
Jun 01 20:16:31 raspberrypi5 AnimalShelter[36353]: 20:16:31.930 [main] INFO me.fazelukario.animalshelter.AnimalShelterApplication -- No active profile set, falling back to 1 default profile: "default"
Jun 01 20:16:32 raspberrypi5 AnimalShelter[36353]: 20:16:32.479 [main] WARN org.springframework.context.annotation.AnnotationConfigApplicationContext -- Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'eventService' defined in URL [jar:file:/root/AnimalShelter/animalshelter.jar!/me/fazelukario/animalshelter/services/EventService.class]: Unsatisfied dependency expressed through constructor parameter 0: No qualifying bean of type 'me.fazelukario.animalshelter.repository.EventRepository' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
Jun 01 20:16:32 raspberrypi5 AnimalShelter[36353]: 20:16:32.487 [main] ERROR org.springframework.boot.SpringApplication -- Application run failed
Jun 01 20:16:32 raspberrypi5 AnimalShelter[36353]: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'eventService' defined in URL [jar:file:/root/AnimalShelter/animalshelter.jar!/me/fazelukario/animalshelter/services/EventService.class]: Unsatisfied dependency expressed through constructor parameter 0: No qualifying bean of type 'me.fazelukario.animalshelter.repository.EventRepository' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
Jun 01 20:16:32 raspberrypi5 AnimalShelter[36353]:         at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:795)
Jun 01 20:16:32 raspberrypi5 AnimalShelter[36353]:         at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:237)
Jun 01 20:16:32 raspberrypi5 AnimalShelter[36353]:         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1355)
Jun 01 20:16:32 raspberrypi5 AnimalShelter[36353]:         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1192)
Jun 01 20:16:32 raspberrypi5 AnimalShelter[36353]:         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:562)
Jun 01 20:16:32 raspberrypi5 AnimalShelter[36353]:         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522)
Jun 01 20:16:32 raspberrypi5 AnimalShelter[36353]:         at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326)
Jun 01 20:16:32 raspberrypi5 AnimalShelter[36353]:         at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
Jun 01 20:16:32 raspberrypi5 AnimalShelter[36353]:         at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324)
Jun 01 20:16:32 raspberrypi5 AnimalShelter[36353]:         at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
Jun 01 20:16:32 raspberrypi5 AnimalShelter[36353]:         at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:975)
Jun 01 20:16:32 raspberrypi5 AnimalShelter[36353]:         at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:962)
Jun 01 20:16:32 raspberrypi5 AnimalShelter[36353]:         at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:624)
Jun 01 20:16:32 raspberrypi5 AnimalShelter[36353]:         at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)
Jun 01 20:16:32 raspberrypi5 AnimalShelter[36353]:         at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456)
Jun 01 20:16:32 raspberrypi5 AnimalShelter[36353]:         at org.springframework.boot.SpringApplication.run(SpringApplication.java:334)
Jun 01 20:16:32 raspberrypi5 AnimalShelter[36353]:         at org.springframework.boot.SpringApplication.run(SpringApplication.java:1354)
Jun 01 20:16:32 raspberrypi5 AnimalShelter[36353]:         at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343)
Jun 01 20:16:32 raspberrypi5 AnimalShelter[36353]:         at me.fazelukario.animalshelter.AnimalShelterApplication.main(AnimalShelterApplication.java:10)
Jun 01 20:16:32 raspberrypi5 AnimalShelter[36353]: Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'me.fazelukario.animalshelter.repository.EventRepository' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
Jun 01 20:16:32 raspberrypi5 AnimalShelter[36353]:         at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1880)
Jun 01 20:16:32 raspberrypi5 AnimalShelter[36353]:         at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1406)
Jun 01 20:16:32 raspberrypi5 AnimalShelter[36353]:         at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1353)
Jun 01 20:16:32 raspberrypi5 AnimalShelter[36353]:         at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:904)
Jun 01 20:16:32 raspberrypi5 AnimalShelter[36353]:         at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:782)
Jun 01 20:16:32 raspberrypi5 AnimalShelter[36353]:         ... 18 common frames omitted

这是错误中提到的代码(EventRepository):

@Repository
public interface EventRepository extends JpaRepository<Event, String> {
    @NonNull
    Optional<Event> findById(@NonNull String id);
}

还有自动装配的部分(EventService):

@Service
@Slf4j
@Transactional(rollbackOn = Exception.class)
@AllArgsConstructor
public class EventService {
    @Autowired
    private EventRepository eventRepository;

当我尝试在同一台机器上使用与在 IntelliJ 中正常运行相同的 jdk 运行编译后的 jar 时,也会出现此错误。

我使用的命令是 C:\Users\MyUser\.jdks\openjdk-22.0.1\bin\java.exe -jar .\animalshelter.jar

帖子版权声明 1、本帖标题:尝试在 ubuntu 上部署 spring boot 应用程序时出现 'UnsatisfiedDependencyException:在 URL 中定义名为 'eventService' 的 bean 时出错'
    本站网址:http://xjnalaquan.com/
2、本网站的资源部分来源于网络,如有侵权,请联系站长进行删除处理。
3、会员发帖仅代表会员个人观点,并不代表本站赞同其观点和对其真实性负责。
4、本站一律禁止以任何方式发布或转载任何违法的相关信息,访客发现请向站长举报
5、站长邮箱:yeweds@126.com 除非注明,本帖由user1111在本站《ubuntu》版块原创发布, 转载请注明出处!
最新回复 (0)
  • 我安装了 libtbb~/work$ sudo find / -name \'libtbb.*\'/usr/lib/x86_64-linux-gnu/libtbb.so/usr/lib/x86_64-linux-gnu/libtbb.so.2Version of g++$ g++ --versiong++ (Ubuntu 7.5.0-3ubuntu...

    我安装了 libtbb

    ~/work$ sudo find / -name "libtbb.*"
    /usr/lib/x86_64-linux-gnu/libtbb.so
    /usr/lib/x86_64-linux-gnu/libtbb.so.2
    

    g++ 的版本

    $ g++ --version
    g++ (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
    Copyright (C) 2017 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    

    操作系统版本

    $ lsb_release -a
    No LSB modules are available.
    Distributor ID: Ubuntu
    Description:    Ubuntu 18.04.6 LTS
    Release:    18.04
    Codename:   bionic
    

    基本程序

    #include <iostream>
    #include <vector>
    #include <tbb/parallel_for.h>
    
    int main() {
        const int N = 1000;
        std::vector<int> array(N, 0);
    
        tbb::parallel_for(0, N, [&](int i) {
            array[i]++;
        });
    
        for (int i = 0; i < 10; ++i) {
            std::cout << array[i] << " ";
        }
        std::cout << std::endl;
    
        return 0;
    }
    

    编译命令

    $ g++ -std=c++11 /usr/lib/x86_64-linux-gnu/libtbb.so parallel_for.cpp -v
    Using built-in specs.
    COLLECT_GCC=g++
    COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
    OFFLOAD_TARGET_NAMES=nvptx-none
    OFFLOAD_TARGET_DEFAULT=1
    Target: x86_64-linux-gnu
    Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.5.0-3ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
    Thread model: posix
    gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) 
    COLLECT_GCC_OPTIONS='-std=c++11' '-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
     /usr/lib/gcc/x86_64-linux-gnu/7/cc1plus -quiet -v -imultiarch x86_64-linux-gnu -D_GNU_SOURCE parallel_for.cpp -quiet -dumpbase parallel_for.cpp -mtune=generic -march=x86-64 -auxbase parallel_for -std=c++11 -version -fstack-protector-strong -Wformat -Wformat-security -o /tmp/ccbdBWm2.s
    GNU C++11 (Ubuntu 7.5.0-3ubuntu1~18.04) version 7.5.0 (x86_64-linux-gnu)
        compiled by GNU C version 7.5.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.19-GMP
    
    GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
    ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/7"
    ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
    ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/7/../../../../x86_64-linux-gnu/include"
    #include "..." search starts here:
    #include <...> search starts here:
     /usr/include/c++/7
     /usr/include/x86_64-linux-gnu/c++/7
     /usr/include/c++/7/backward
     /usr/lib/gcc/x86_64-linux-gnu/7/include
     /usr/local/include
     /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed
     /usr/include/x86_64-linux-gnu
     /usr/include
    End of search list.
    GNU C++11 (Ubuntu 7.5.0-3ubuntu1~18.04) version 7.5.0 (x86_64-linux-gnu)
        compiled by GNU C version 7.5.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.19-GMP
    
    GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
    Compiler executable checksum: 3eb3dc290cd5714c3e1c3ae751116f07
    COLLECT_GCC_OPTIONS='-std=c++11' '-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
     as -v --64 -o /tmp/ccTBaR0N.o /tmp/ccbdBWm2.s
    GNU assembler version 2.30 (x86_64-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.30
    COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/
    LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../:/lib/:/usr/lib/
    COLLECT_GCC_OPTIONS='-std=c++11' '-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
     /usr/lib/gcc/x86_64-linux-gnu/7/collect2 -plugin /usr/lib/gcc/x86_64-linux-gnu/7/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper -plugin-opt=-fresolution=/tmp/cc8wDjGz.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -z now -z relro /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/7/crtbeginS.o -L/usr/lib/gcc/x86_64-linux-gnu/7 -L/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/7/../../.. /usr/lib/x86_64-linux-gnu/libtbb.so /tmp/ccTBaR0N.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/7/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/crtn.o
    /tmp/ccTBaR0N.o: In function `tbb::interface9::internal::start_for<tbb::blocked_range<int>, tbb::internal::parallel_for_body<main::{lambda(int)#1}, int>, tbb::auto_partitioner const>::run(tbb::blocked_range<int> const&, main::{lambda(int)#1} const&, tbb::auto_partitioner&)':
    parallel_for.cpp:(.text+0x3d5): undefined reference to `tbb::task_group_context::~task_group_context()'
    parallel_for.cpp:(.text+0x3fc): undefined reference to `tbb::task_group_context::~task_group_context()'
    /tmp/ccTBaR0N.o: In function `tbb::task_group_context::task_group_context(tbb::task_group_context::kind_type, unsigned long)':
    parallel_for.cpp:(.text._ZN3tbb18task_group_contextC2ENS0_9kind_typeEm[_ZN3tbb18task_group_contextC5ENS0_9kind_typeEm]+0x46): undefined reference to `tbb::task_group_context::init()'
    /tmp/ccTBaR0N.o: In function `tbb::task::task()':
    parallel_for.cpp:(.text._ZN3tbb4taskC2Ev[_ZN3tbb4taskC5Ev]+0x1b): undefined reference to `vtable for tbb::task'
    /tmp/ccTBaR0N.o: In function `tbb::task::~task()':
    parallel_for.cpp:(.text._ZN3tbb4taskD2Ev[_ZN3tbb4taskD5Ev]+0xb): undefined reference to `vtable for tbb::task'
    /tmp/ccTBaR0N.o: In function `tbb::task::is_cancelled() const':
    parallel_for.cpp:(.text._ZNK3tbb4task12is_cancelledEv[_ZNK3tbb4task12is_cancelledEv]+0x24): undefined reference to `tbb::task_group_context::is_group_execution_cancelled() const'
    /tmp/ccTBaR0N.o: In function `operator new(unsigned long, tbb::internal::allocate_root_with_context_proxy const&)':
    parallel_for.cpp:(.text._ZnwmRKN3tbb8internal32allocate_root_with_context_proxyE[_ZnwmRKN3tbb8internal32allocate_root_with_context_proxyE]+0x1f): undefined reference to `tbb::internal::allocate_root_with_context_proxy::allocate(unsigned long) const'
    /tmp/ccTBaR0N.o: In function `operator delete(void*, tbb::internal::allocate_root_with_context_proxy const&)':
    parallel_for.cpp:(.text._ZdlPvRKN3tbb8internal32allocate_root_with_context_proxyE[_ZdlPvRKN3tbb8internal32allocate_root_with_context_proxyE]+0x1f): undefined reference to `tbb::internal::allocate_root_with_context_proxy::free(tbb::task&) const'
    /tmp/ccTBaR0N.o: In function `operator new(unsigned long, tbb::internal::allocate_continuation_proxy const&)':
    parallel_for.cpp:(.text._ZnwmRKN3tbb8internal27allocate_continuation_proxyE[_ZnwmRKN3tbb8internal27allocate_continuation_proxyE]+0x1f): undefined reference to `tbb::internal::allocate_continuation_proxy::allocate(unsigned long) const'
    /tmp/ccTBaR0N.o: In function `operator delete(void*, tbb::internal::allocate_continuation_proxy const&)':
    parallel_for.cpp:(.text._ZdlPvRKN3tbb8internal27allocate_continuation_proxyE[_ZdlPvRKN3tbb8internal27allocate_continuation_proxyE]+0x1f): undefined reference to `tbb::internal::allocate_continuation_proxy::free(tbb::task&) const'
    /tmp/ccTBaR0N.o: In function `tbb::internal::throw_exception(tbb::internal::exception_id)':
    parallel_for.cpp:(.text._ZN3tbb8internal15throw_exceptionENS0_12exception_idE[_ZN3tbb8internal15throw_exceptionENS0_12exception_idE]+0x11): undefined reference to `tbb::internal::throw_exception_v4(tbb::internal::exception_id)'
    /tmp/ccTBaR0N.o: In function `tbb::interface9::internal::allocate_sibling(tbb::task*, unsigned long)':
    parallel_for.cpp:(.text._ZN3tbb10interface98internal16allocate_siblingEPNS_4taskEm[_ZN3tbb10interface98internal16allocate_siblingEPNS_4taskEm]+0x7e): undefined reference to `tbb::internal::allocate_child_proxy::allocate(unsigned long) const'
    /tmp/ccTBaR0N.o: In function `tbb::interface9::internal::adaptive_mode<tbb::interface9::internal::auto_partition_type>::adaptive_mode()':
    parallel_for.cpp:(.text._ZN3tbb10interface98internal13adaptive_modeINS1_19auto_partition_typeEEC2Ev[_ZN3tbb10interface98internal13adaptive_modeINS1_19auto_partition_typeEEC5Ev]+0xd): undefined reference to `tbb::internal::get_initial_auto_partitioner_divisor()'
    /tmp/ccTBaR0N.o:(.data.rel.ro._ZTVN3tbb10interface98internal9flag_taskE[_ZTVN3tbb10interface98internal9flag_taskE]+0x28): undefined reference to `tbb::task::note_affinity(unsigned short)'
    /tmp/ccTBaR0N.o:(.data.rel.ro+0x10): undefined reference to `typeinfo for tbb::task'
    /tmp/ccTBaR0N.o:(.data.rel.ro._ZTIN3tbb10interface98internal9flag_taskE[_ZTIN3tbb10interface98internal9flag_taskE]+0x10): undefined reference to `typeinfo for tbb::task'
    collect2: error: ld returned 1 exit status
    
返回
作者最近主题: