简体   繁体   English

Spring Web应用程序注释驱动-如何配置? (最佳实践)

[英]Spring web-app annotation driven - How to configure? (Best Practice)

I'm developing bunch of relatively small Spring based java web-application. 我正在开发一堆相对较小的基于Spring的Java Web应用程序。 I'm mostly using annotations to create controllers and components. 我主要使用注释来创建控制器和组件。 What's the best way to configure such application? 配置此类应用程序的最佳方法是什么?

I'm writing my own "configuration beans" that are just value beans with needed fields and @autowire them into other beans 我正在编写自己的“配置bean”,它们只是具有所需字段的值bean,然后将它们@autowire插入其他bean

this way my config.xml contains of "just" component-scan and definition of config-beans (2-3 per app) 这样我的config.xml包含“just”组件扫描和config-beans的定义(每个应用程序2-3个)

Is this good approach? 这是好方法吗?

There is nothing wrong with this approach. 这种方法没有错。 Folks prefer it this way. 人们更喜欢这种方式。 So, go with it, I would say. 所以,我会说,顺其自然。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Web应用程序中使用Spring自动装配注释 - How to use Spring autowire annotation in a web-app 使用Java web-app(web.xml)部署数据库配置(用户名/密码)的最佳做法是什么? - What is the best practice to deploy database config (username/password) with Java web-app (web.xml)? 在基于注释的Spring Web应用程序中进入控制器之前拦截请求 - Intercepting requests before they go to the controller in an annotation-based Spring web-app 如何解决 Spring 中的 web-app 必须声明错误? - How to solve web-app must be declared error in Spring? 春季启动:web-app + webservice - Spring Boot: web-app + webservice 如何正确配置 web 应用程序,以便axis2 找到所需的模块? - How to configure a web-app correctly, so that axis2 finds required modules? 如何配置Jetty服务器以禁止Web应用程序开发服务器外部的连接? - How to configure Jetty server to forbid connections external to the web-app development server? 如何在Java Web应用程序中更改语言环境? - How to change the Locale in a java web-app? 我的Singleton类(Web应用程序,Tomcat)的Spring和IoC - Spring and IoC for my Singleton class (web-app, Tomcat) 春季2至4:Web应用程序上下文中缺少bean - Spring 2 to 4: beans missing from web-app context
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM