目前我正在尝试为我正在工作的学校项目设置Spring MVC Controller测试.通常我在像Laravel这样的php和框架中编程,所以这对我来说很新.问题是我无法弄清楚如何解决在加载ApplicationContext时不断弹出的问题.任何帮助表示赞赏.
更新:
我现在被告知,测试用例不会在我的应用服务器中使用jndi ref.所以这个引用在测试用例上会失败,它在启动应用程序时运行良好.现在我创建了第二个文件servlet-test.xml (listed below),它在端口3306上使用对数据库的引用.我只在测试时使用此文件而不是在启动应用程序时.但是当我使用这种方法时,我得到了 Following error: Error creating bean with name 'productController': Injection of autowired dependencies failed.欢迎任何帮助,因为我正在努力为我的学校项目设置MVC控制器测试.我一直在和我一起工作的其他学生也遇到了同样的问题,所以我也可以帮助他们.
我怀疑问题如下,但我不知道如何解决这个问题.
Error creating bean with name 'myDataSource' defined in URL
[file:web/WEB-INF/servlet.xml]: Invocation of init method failed;
nested exception is javax.naming.NamingException: Lookup failed for
'java:app/fotoproducent' ...
Run Code Online (Sandbox Code Playgroud)
错误堆栈跟踪
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in URL [file:web/WEB-INF/servlet.xml]: Cannot resolve reference to bean 'myDataSource' while setting bean property 'dataSource'; nested …Run Code Online (Sandbox Code Playgroud) 只是一个简单的问题,是否可以将 ng-model 中名为“id”的字符串连接到 angularjs 中的变量 product.id?有没有办法像这样的方法实际上可以工作?
这有效:
ng-model="currentQuantity['id1']"
Run Code Online (Sandbox Code Playgroud)
这不起作用:
ng-model='currentQuantity[id + "" + product.id]'
Run Code Online (Sandbox Code Playgroud) 在 Vue 2 中,您可以通过在index.js 中使用以下代码在多个文件上全局注册组件,而不会膨胀main.js文件
import Vue from 'vue'
import MyComponent from '@/components/MyComponent'
Vue.component('my-component-name', MyComponent)
Run Code Online (Sandbox Code Playgroud)
并在main.js文件中使用
import '@/components'
Run Code Online (Sandbox Code Playgroud)
但是这种方法在 Vue 3 中似乎对我不起作用
主文件
import { createApp } from 'vue';
import '@/components'
const app = createApp({});
app.mount("#app");
Run Code Online (Sandbox Code Playgroud)
索引.js
import Vue from 'vue' // doesn't work with import { createApp } from 'vue' too
import MyComponent from '@/components/MyComponent'
Vue.component('my-component-name', MyComponent)
Run Code Online (Sandbox Code Playgroud)
如何在 Vue 3 中获得相同的结果?