dependency-injection

Angular 6 - can't resolve all parameters for AppComponent

前提是你 提交于 2020-01-31 04:44:29
问题 I am trying to build an application with Angular 6 and I am still setting everything up. But it seems there is something wrong with the dependency injection in my app. It cannot resolve any constructor parameter. They all result in Uncaught Error: Can't resolve all parameters for AppComponent: (?). . Even a custom service results in the same error. Versions (omitted the dependencies that can't have any influence on this) "dependencies": { "@angular/common": "6.0.5", "@angular/compiler": "6.0

Guice: How to change injection on runtime based on a (dynamic web property)

心不动则不痛 提交于 2020-01-30 19:36:07
问题 The following is an approximation of the problem I'm facing. Think we have a password validator with some rules. public interface RuleChecker{ //Checks for a password strenght, returns 10 //for strong or 0 for soft password. int check(String pass); } And then we have several implementations, our service will only accept the password if it is over 8 score. public class NoCheck implements RuleChecker { public int check(String pass){return 10;} } public class LengthCheck implements RuleChecker{

Symfony2: ContextErrorException: Catchable Fatal Error: Argument 1 passed to […]::__construct() must implement interface […] none given

淺唱寂寞╮ 提交于 2020-01-30 11:21:26
问题 The problem: Any time I try to access the application I get this error: ContextErrorException: Catchable Fatal Error: Argument 1 passed to PL\OrderBundle\Entity\OrderHasComment::__construct() must implement interface Symfony\Component\Security\Core\SecurityContextInterface, none given, called in /var/www/html/apps/portal_de_logistica/vendor/sonata-project/doctrine-orm-admin-bundle/Model/ModelManager.php on line 416 and defined in /var/www/html/apps/portal_de_logistica/src/PL/OrderBundle

My spring bean is not injected or created when I use the autowire and component annotations

安稳与你 提交于 2020-01-30 09:31:13
问题 I'm trying to understand DI, but my spring bean is not injected or created when I use the autowire and component annotations. Instead I get a nullpointer exception because my bean is null. Should I created it manually and in that case where? Where do you specify the order in which the beans are created, when several beans depend on each other? Here is my code: App.java package se.springtest; import se.springtest.Person; import org.springframework.core.io.ClassPathResource; import org

Spring Best practice for Dependency Injection

我的未来我决定 提交于 2020-01-30 08:39:49
问题 I have some confusion about DI in spring public interface A{ void methodA(); } public class AImpl implements A{ public void methodA(){ // todo something } } public interface B{ void methodB(); } public class BImpl implements B{ public void methodB(){ //todo somethong } } I have two interface A and B and 2 class implements it. So, I have 2 Class that implement interface C, it depend on Interface A and B This is case 1: public interface C{ void methodC(); } public class CAutowired implements C{

How to configure ASP.NET Identity ApplicationUserManager with StructureMap

醉酒当歌 提交于 2020-01-29 04:48:05
问题 I am using asp.net identity in my project and using structuremap as DI framework. the problem is when i use constructor injection then ApplicationUserManager not configured all of it's members e.g TokenProvider, ... this is my ApplicationUserManager class: public class ApplicationUserManager : UserManager<User, long> { public ApplicationUserManager(IUserStore<User, long> store) : base(store) { } public static ApplicationUserManager Create(IdentityFactoryOptions<ApplicationUserManager> options

How to set up IoC when a key class needs Session (or other context-specific variable)

那年仲夏 提交于 2020-01-28 05:18:17
问题 I am trying to figure out how to use IoC in situations where the dependent classes can change based on some variable in the application (in this case, Session state). For example, each of our clients have a different database, so the connection to the database needs to be built on a value stored in their Session (particularly since some users could have multiple databases if they own multiple businesses, and would switch between databases). Here is a generic example of how we'd currently set

How to set up IoC when a key class needs Session (or other context-specific variable)

痞子三分冷 提交于 2020-01-28 05:17:06
问题 I am trying to figure out how to use IoC in situations where the dependent classes can change based on some variable in the application (in this case, Session state). For example, each of our clients have a different database, so the connection to the database needs to be built on a value stored in their Session (particularly since some users could have multiple databases if they own multiple businesses, and would switch between databases). Here is a generic example of how we'd currently set

Why not use an IoC container to resolve dependencies for entities/business objects?

旧时模样 提交于 2020-01-26 05:15:21
问题 I understand the concept behind DI, but I'm just learning what different IoC containers can do. It seems that most people advocate using IoC containers to wire up stateless services, but what about using them for stateful objects like entities? Whether it's right or wrong, I normally stuff my entities with behavior, even if that behavior requires an outside class. Example: public class Order : IOrder { private string _ShipAddress; private IShipQuoter _ShipQuoter; public Order(IOrderData

Constructor Injection vs Setter Injection

南笙酒味 提交于 2020-01-26 04:15:27
问题 I have read the following as one of the difference between constructor and setter injection. Can someone explain the below difference with some simple example, I'm bit confused with the term fully function object and incomplete object. -> Constructor DI allows object to be created in complete state and follows principle of fully functional object while Setter DI allows object to be created without its dependency. which may result in incomplete object if dependency is not available. 回答1: When