Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package mypackage;
- import java.util.function.Consumer;
- import javax.inject.*;
- import javax.dependent.*;
- import java.lang.reflect.*;
- import javax.annotation.*;
- public class MyFirstObject {
- @Inject
- public static MyTest test;
- public static String MyTest;
- public static MyTest test2; //tutaj mam obiekt MyTest
- public static void main(String[] args) {
- System.out.println("Works");
- //tu wyswietla poprawnie 2
- System.out.println(getNumber());
- //to wyswietli This is a value null
- System.out.println("This is a value " + MyTest);
- }
- public static String getNumber() {
- return test.number();
- }
- @Inject
- public static void getNumber2(MyTest myTest) {
- String MyTest = myTest.number();
- }
- @Inject
- public static void getNumber2(MyTest myTest) {
- test2 = myTest.number();
- }
- }
- package mypackage;
- public class MyTest
- {
- public static String number()
- {
- return "2";
- }
- }
- // GRADLE
- repositories {
- mavenCentral()
- jcenter()
- }
- apply plugin: "java"
- apply plugin: "war"
- apply plugin: "jetty"
- dependencies {
- compile "org.apache.commons:commons-lang3:3.4"
- compile "javax.servlet:javax.servlet-api:3.0.1"
- compile "org.apache.commons:commons-io:1.3.2"
- compile 'javax.inject:javax.inject:1'
- testCompile 'info.cukes:cucumber-java:1.2.4'
- testCompile 'info.cukes:cucumber-junit:1.2.4'
- testCompile 'junit:junit:4.11'
- testCompile "org.mockito:mockito-core:2.0.86-beta"
- }
- sourceSets {
- main.java.srcDir "src/main"
- test.java.srcDir "src/test"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement