当我在 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
$ 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
# where are the images initially stored?
sudo docker info | grep "Root Dir"
# ... not where I want them
# modify the configuration files to change to image location
# NOTE this generates an error
# WARNING: Usage of loopback devices is strongly discouraged for production use.
# Use `--storage-opt dm.thinpooldev` to specify a custom block storage device.
# see https://.com/questions/31620825/
# warning-of-usage-of-loopback-devices-is-strongly-discouraged-for-production-use
sudo sed -i ' s@#DOCKER_OPTS=.*@DOCKER_OPTS="-g /home/ubuntu/kaggle/docker"@ ' /etc/default/docker
sudo chmod -R ugo+rw /lib/systemd/system/docker.service
sudo cp /lib/systemd/system/docker.service /etc/systemd/system/
sudo chmod -R ugo+rw /etc/systemd/system/
sudo sed -i ' s@ExecStart.*@ExecStart=/usr/bin/dockerd $DOCKER_OPTS -H fd://@ ' /etc/systemd/system/docker.service
sudo sed -i '/ExecStart/a EnvironmentFile=-/etc/default/docker' /etc/systemd/system/docker.service
sudo systemctl daemon-reload
sudo systemctl restart docker
sudo docker info | grep "Root Dir"
# now they're where I want them