0 Replies Latest reply on Dec 10, 2018 5:21 AM by tangara Goh

    Can we just use @inject alone to make one to many and many to one work ?

    tangara Goh Newbie

      Hi,

       

      Recently, I chanced upon using Weld for CDI in Java EE.

       

      Correct me if I am wrong cos I don't have much infor.

       

      Basically, I want to use dependency injection in my web app, as I find it difficult for 1 entity to set it to another entity.

       

      I have 2 entities - tutor and subject.

       

      I need tutor to set the List<Subject> and used it in my controller.

       

      My question is do I just use @inject alone when I put Subject subject at Tutor class or ?

       

      So far, I have the below dependencies in maven pom.

       

      <!-- https://mvnrepository.com/artifact/javax.inject/javax.inject -->

              <dependency>

                  <groupId>javax.inject</groupId>

                  <artifactId>javax.inject</artifactId>

                  <version>1</version>

              </dependency>

       

      <dependency>

                  <groupId>org.jboss.weld.servlet</groupId>

                  <artifactId>weld-servlet</artifactId>

                  <version>2.4.5.Final</version>

                  <scope>runtime</scope>

              </dependency>

      I am using Tomcat as server and Eclipse as IDE.